Type: Default 1000ms 256MiB

递增数组

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目背景

翻译自 CSES-1094 题。

题目描述

给你一个包含 nn 个整数的数组。你想要修改数组中元素,使得数组是递增的(单调不降),换句话说,数组中的每一个元素至少需要大于等于前一个元素。

每一次操作,你可以将数组中的任意一个元素的值加 11。问最少需要操作多少次才能得到递增(单调不降)数组。

输入格式

第一行输入一个整数 nn 表示数组的元素个数。

第二行输入 nn 个整数 a1,a2,,ana_1,a_2,\cdots,a_n

输出格式

输出一行一个整数表示最少操作次数。

样例

5
3 2 5 1 7
5

说明/提示

1n2×105,1ai1091\le n \le 2\times 10^5,1\le a_i\le 10^9