Write a program to find the minimum number of operations needed to sort in nondecreasing order ().
It can be shown that for every input satisfying the constraints, the sequence can be sorted in nondecreasing order using the given operation.
The first line contains an integer .
The next line contains space-separated integers in that order.
Print the minimum number of operations needed to sort in nondecreasing order on the first line.
The sequence can be sorted in nondecreasing order in operation as follows.
The sequence can be sorted in nondecreasing order in operations as follows.
It can be shown that fewer than operations cannot sort in nondecreasing order.