Joe is making a domino trail. After placing all the pieces, he decides to change the trail so the heights of the dominoes (strictly) increase then (strictly) decrease. Find the minimum number of dominoes he must remove. (A strictly increasing sequence satisfies and a strictly decreasing sequence satisfies ).
Input Specification
The first line of input contains a single integer .
The next line contains space-seperated integers .
Output Specification
Output the minimum number of dominoes to remove.
The maximal height must satisfy .
It is guaranteed that there is at least one valid solution.
Sample Input
10
1 2 3 5 4 6 2 4 3 1
Sample Output
2
Explanation
Joe can remove dominoes and to get the sequence
Comments