This is a Mooshak version of a CSES problem.


[PC002] Increasing Array

You are given an array of \(n\) 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 may increase the value of any element by one. What is the minimum number of moves required?

Input

The first input line contains an integer \(n\): the size of the array.

Then, the second line contains \(n\) integers \(x_1,x_2,\ldots,x_n\): the contents of the array.

Output

Print a line with one integer: the minimum number of moves.

Constraints

Example Input Example Output
5
3 2 5 1 7
5

Competitive Programming (CC3032) 2025/2026
DCC/FCUP - University of Porto