CF11A.Increasing Sequence

传统题 时间 2000 ms 内存 256 MiB 4 尝试 1 已通过 1 标签

Increasing Sequence

A sequence a0, a1, ..., a**t - 1 is called increasing if a**i - 1 < a**i for each i: 0 < i < t.

You are given a sequence b0, b1, ..., b**n - 1 and a positive integer d. In each move you may choose one element of the given sequence and add d to it. What is the least number of moves required to make the given sequence increasing?

Input

The first line of the input contains two integer numbers n and d (2 ≤ n ≤ 2000, 1 ≤ d ≤ 106). The second line contains space separated sequence b0, b1, ..., b**n - 1 (1 ≤ b**i ≤ 106).

Output

Output the minimal number of moves needed to make the sequence increasing.

Samples

4 2
1 3 3 2
3

在线编程 IDE

建议全屏模式获得最佳体验