{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"题目解释","value":{"format":"MD","content":"Polycarp喜欢等差数列。如果对于每个 $i$ ($1 \\le i \u003c n$),值 $a_{i+1} - a_i$ 都是相同的,那么序列 $[a_1, a_2, \\dots, a_n]$ 就被称为等差数列。例如,序列 $[42]$、$[5, 5, 5]$、$[2, 11, 20, 29]$ 和 $[3, 2, 1, 0]$ 是等差数列,但 $[1, 0, 1]$、$[1, 3, 9]$ 和 $[2, 3, 1]$ 不是。\n\n根据定义,任何长度为一或二的序列都是等差数列。\n\nPolycarp找到了一些正整数序列 $[b_1, b_2, \\dots, b_n]$。他同意最多改变每个元素一次。换句话说,对于每个元素,都有三个选项:元素可以减少 $1$,元素可以增加 $1$,元素可以保持不变。\n\n确定在 $b$ 中可以改变的元素的最小可能数量(精确地说,是一个),以便序列 $b$ 成为等差数列,或者报告这是不可能的。\n\n结果序列可能包含等于 $0$ 的元素。"}},{"title":"输入格式","value":{"format":"MD","content":"输入的第一行包含一个单独的整数 $n$ ($1 \\le n \\le 100\\,000$) —— $b$ 中的元素数量。\n\n第二行包含一个序列 $b_1, b_2, \\dots, b_n$ ($1 \\le b_i \\le 10^{9})$。"}},{"title":"输出格式","value":{"format":"MD","content":"如果无法通过描述的操作制作等差数列,打印 $-1$。在其他情况下,打印非负整数 —— 为使给定序列变为等差数列,需要改变的元素的最小数量。唯一允许的操作是对元素加/减一(不能对同一位置使用两次操作)。"}},{"title":"样例 #1","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003e输入\u003c/th\u003e\n \u003cth\u003e输出\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\n24 21 14 10\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"样例 #2","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003e输入\u003c/th\u003e\n \u003cth\u003e输出\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\n500 500\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"样例 #3","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003e输入\u003c/th\u003e\n \u003cth\u003e输出\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3\n14 5 1\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e-1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"样例 #4","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003e输入\u003c/th\u003e\n \u003cth\u003e输出\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5\n1 3 6 9 12\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"样例解释","value":{"format":"MD","content":"在第一个例子中,Polycarp应该将第一个数字增加 $1$,将第二个数字减少 $1$,将第三个数字增加 $1$,第四个数字应保持不变。所以,Polycarp改变了三个元素后,他的序列变成了 $[25, 20, 15, 10]$,这是一个等差数列。\n\n在第二个例子中,Polycarp不应该改变任何东西,因为他的序列是一个等差数列。\n\n在第三个例子中,不可能制作出等差数列。\n\n在第四个例子中,Polycarp应该只改变第一个元素,他应该将其减少一个。之后他的序列将看起来像 $[0, 3, 6, 9, 12]$,这是一个等差数列。"}}]}