Manual sorting#1883

Manual sorting

2 seconds
256 megabytes
Very hard

It's time to arrange the books on the shelf. There are books, each uniquely numbered from to . Your goal is to arrange them in ascending order of their numbers. You know that quicksort and insertion sort are efficient for computers, but they are not practical for manual sorting.

Therefore, you decide to sort the books by inserting the -th book into the -th position. How many such operations are required to successfully sort the books? Here are two examples of such operations:

1\ 3\ 4\ 5\ 2 \Rightarrow 1\ 2\ 3\ 4\ 5, by inserting into its proper position.

1\ 3\ 4\ 5\ 2 \Rightarrow 1\ 4\ 3\ 5\ 2, by inserting into its proper position.

Input

The first line contains an integer (1 \leq n \leq 20) — the number of books on the shelf.

The second line contains distinct integers from to — the initial order of the books.

Output

Output a single integer — the minimum number of operations of this kind needed to sort the books.

Examples

Example 1

Loading
Loading