- Time limit: 1.00 s
- Memory limit: 512 MB
You are given an array of integers. You want to modify the array so that it is increasing, i.e., every element is at least as large as the previous element.
On each move, you can increase or decrease the value of any element by one. What is the minimum number of moves required?
Input
The first input line contains an integer : the size of the array.
Then, the second line contains integers : the contents of the array.
Output
Print the minimum number of moves.
Constraints
Example
Input:
5 3 8 5 6 5
Output:
4