3159: 序列修改

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

给出数列{$A_1,A_2,...,A_N$},修改最少的元素,使得数列{$A_N$}成为一个公差为1的等差数列。

Input

第1行,1个整数N。
第2行,N个整数$A_1,A_2,……,A_N。$

Output

一个整数,表示最少修改的数字。

Sample Input Copy

3
2 1 4

Sample Output Copy

1

HINT

【数据范围与约定】 对于40%的数据,$n <= 1000$; 对于100%的数据,$n <= 10^5,1<=A_i<=10^6$。