Sort Machine
Easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
There is a machine for sorting a set of different numbers. It has only one command, MOVE, with one argument. This command moves the number specified in the argument to the end of the sequence. For example, to sort the array of numbers in ascending order, two commands should be performed:
MOVE 19, resulting in .
MOVE 25, resulting in .
For a given set of numbers, find the minimum number of MOVE commands required to arrange its elements in ascending order.
Input
The first line contains the number . The second line contains integers in the range from to .
Output
Print the minimum number of MOVE commands required to arrange all the numbers in ascending order.
Submissions 2K
Acceptance rate 25%