Score : 2400 points
Takahashi loves sorting.
He has a permutation (p_1,p_2,...,p_N) of the integers from 1 through N. Now, he will repeat the following operation until the permutation becomes (1,2,...,N):
How many operations are necessary until the permutation is sorted?
Input is given from Standard Input in the following format:
N p_1 p_2 ... p_N
Print the number of operations that are necessary until the permutation is sorted.
5 3 5 1 2 4
3
The initial permutation is (3,5,1,2,4), and each operation changes it as follows:
5 5 4 3 2 1
4
10 2 10 5 7 3 6 4 9 8 1
6