Sonya and Problem Wihtout a Legend
时间限制:C/C++/Rust/Pascal 5秒,其他语言10秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Sonya was unable to think of a story for this problem, so here comes the formal description.

You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the array strictly increasing by making the minimum possible number of operations. You are allowed to change elements in any way, they can become negative or equal to 0.

输入描述:

The first line of the input contains a single integer n (1 ≤ n ≤ 3000) — the length of the array.

Next line contains n integer ai (1 ≤ ai ≤ 109).

输出描述:

Print the minimum number of operation required to make the array strictly increasing.

示例1

输入

复制
7
2 1 5 11 5 9 11

输出

复制
9
示例2

输入

复制
5
5 4 3 2 1

输出

复制
12

备注:

In the first sample, the array is going to look as follows:

23567911

|2 - 2| + |1 - 3| + |5 - 5| + |11 - 6| + |5 - 7| + |9 - 9| + |11 - 11| = 9

And for the second sample:

12345

|5 - 1| + |4 - 2| + |3 - 3| + |2 - 4| + |1 - 5| = 12