Sorter
The corporation is designing a sorting device to organize numbers. This device consists of N memory elements, each holding a number. Sorting is achieved through swap operations between specific pairs of elements. However, it is not feasible to connect all pairs of elements. Therefore, swaps can only occur between the first element and any other element.
Your task is to determine the minimum number of swap operations required to sort the numbers stored in the memory elements in ascending order, given their initial arrangement.
Input
The first line of the input contains a natural number N (1 ≤ N ≤ 30000).
The second line contains N distinct integers, initially positioned in the first, second, ..., N-th memory element. Each number is within the range from 0 to 30000 inclusive.
Output
Output a single number M — the minimum number of swap operations needed between pairs of memory elements to sort the numbers in ascending order.