Non-Decreasing Necessity
Given an array of n
integers, you are asked to make the array non-decreasing by performing the following operation zero or more times:
Choose any index i
(1 ≤ i ≤ n) and replace with any integer.
Your goal is to minimize the number of operations required to make the array non-decreasing.
Input
The first line of the input contains a single integer n
(1 ≤ n ≤ 100 000), the length of the array.
The second line contains n
space-separated integers (1 ≤ ≤ ).
Output
The program should print a single integer — the minimum number of operations required to make the array non-decreasing.
Examples
Input | Output |
---|---|
7 | 3 |
4 | 1 |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB