cswork / OA打开练习工作台

WalmartOA #4

Minimum Possible Value of Function

估计中等可在线判题

考点(AI 标注)位运算原地数组

Given a sequence X, find an integer k that minimizes Σ|X[i]−(k+i+1)|, and output the minimum value.

The standard input/output format and any supplementary ranges on this site are as stated in this problem.

输入格式

n (1≤n≤200000), and the next line has n integers X[i] (1≤X[i]≤10^9).

输出格式

Output the minimum value of the function as an integer.

样例 1

输入:

5
2 2 3 5 5

输出:

2

样例 2

输入:

1
1

输出:

0

样例 3

输入:

3
10 1 10

输出:

10