Polycarp likes arithmetic progressions. A sequence [a1,a2,…,an] is called an arithmetic progression if for each i (1≤i It follows from the definition that any sequence of length one or two is an arithmetic progression. Polycarp found some sequence of positive integers [b1,b2,…,bn]. He agrees to change each element by at most one. In the other words, for each element there are exactly three options: an element can be decreased by 1, an element can be increased by 1, an element can be left unchanged. Determine a minimum possible number of elements in b which can be changed (by exactly one), so that the sequence b becomes an arithmetic progression, or report that it is impossible. It is possible that the resulting sequence contains element equals 0. Input The first line contains a single integer n (1≤n≤100000) — the number of elements in b. The second line contains a sequence b1,b2,…,bn (1≤bi≤10^9). Output If it is impossible to make an arithmetic progression with described operations, print -1. In the other case, print non-negative integer — the minimum number of elements to change to make the given sequence becomes an arithmetic progression. The only allowed operation is to add/to subtract one from an element (can't use operation twice to the same position). input output 题意:给定n个数的序列,对于每一个数,可以进行+1,-1,不动,三种操作,注意每个数只能操作一次,问最少需要操作多少次使得整个序列变成等差序列,如果无解输出-1. 解析:等差数列的特点,如果首项和公差知道,那么整个序列就都知道了,因此我们枚举前两项所有的可能,一共九种,对于每种合法情况对答案取min即可。3