294 传统题

[CF713C] 严格递增最小修改代价 (Sonya and Problem Without a Legend)

时间限制
5000ms
内存限制
256MiB
登顶 / 尝试
0/ 0
难度
5

[CF713C] 严格递增最小修改代价 (Sonya and Problem Without a Legend)

Problem Statement

You are given an array aa of nn positive integers. In one move, you can increase or decrease any element by 11 (elements may become 00 or negative).

Find the minimum number of moves required to make the array strictly increasing.

Input

The first line contains nn (1≤n≤30001 \le n \le 3000). The second line contains nn integers a1,…,ana_1, \dots, a_n (1≤ai≤1091 \le a_i \le 10^9).

Output

Print the minimum number of moves.

Example

7
2 1 5 11 5 9 11
9

Note