{"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":"HTML","content":"\u003cp\u003ePolycarp 喜欢等差数列。\u003c/p\u003e\n\n\u003cp\u003ePolycarp 得到了一个正整数序列 [b\u003csub\u003e1\u003c/sub\u003e,b\u003csub\u003e2\u003c/sub\u003e,…,b\u003csub\u003en\u003c/sub\u003e] ,他决定把这个数列变成等差数列。对于数列中的每个元素,他可以选择一种操作:减1、加1或保持不变。\u003c/p\u003e\n\n\u003cp\u003e请你求出最小的操作次数,使得数列b变成一个等差数列,或者判断这是不可能的。\u003c/p\u003e\n\n\u003cp\u003e我们规定,任何长度为 1 或 2 的数列是等差数列。操作产生的数列可以包含 0 。\u003c/p\u003e"}},{"title":"【输入格式】","value":{"format":"HTML","content":"\u003cp\u003e第一行包含一个整数 n (1≤n≤10\u003csup\u003e5\u003c/sup\u003e),表示 b 中的元素个数。\u003c/p\u003e\n\n\u003cp\u003e第二行包含一个数列 b\u003csub\u003e1\u003c/sub\u003e,b\u003csub\u003e2\u003c/sub\u003e,…,b\u003csub\u003en\u003c/sub\u003e (1≤b\u003csub\u003ei\u003c/sub\u003e≤10\u003csup\u003e9\u003c/sup\u003e)。\u003c/p\u003e"}},{"title":"【输出格式】","value":{"format":"HTML","content":"\u003cp\u003e如果不可能通过上述操作得到等差数列,请输出 -1 。\u003c/p\u003e\n\n\u003cp\u003e否则,输出一个非负整数,表示使给定序列成为等差数列所需的最少操作次数。\u003c/p\u003e"}},{"title":"【样例输入/输出】","value":{"format":"HTML","content":"\u003ctable border\u003d\"1\" width\u003d\"100%\"\u003e\n\n\u003ctr\u003e\n\t\u003ctd width\u003d\"50%\"\u003e 输入 \u003c/td\u003e\n\t\u003ctd width\u003d\"50%\"\u003e 输出 \u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\t\u003ctd\u003e\n\t\t4 \u003cbr\u003e \n\t\t24 21 14 10 \u003cbr\u003e\n\t\u003c/td\u003e\n\t\u003ctd\u003e\n\t\t3 \u003cbr\u003e\n\t\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\t\u003ctd\u003e\n\t\t2 \u003cbr\u003e\n\t\t500 500 \u003cbr\u003e\n\t\u003c/td\u003e\n\t\u003ctd\u003e\n\t\t0 \u003cbr\u003e\n\t\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\t\u003ctd\u003e\n\t\t3 \u003cbr\u003e\n\t\t14 5 1 \u003cbr\u003e\n\t\u003c/td\u003e\n\t\u003ctd\u003e\n\t\t-1 \u003cbr\u003e\n\t\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\t\u003ctd\u003e \n\t\t5 \u003cbr\u003e\n\t\t1 3 6 9 12 \u003cbr\u003e\n\t\u003c/td\u003e\n\t\u003ctd\u003e\n\t\t1 \u003cbr\u003e\n\t\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003c/table\u003e"}},{"title":"【样例解释】","value":{"format":"HTML","content":"\u003cp\u003e在样例一中,最终的数列为:[25,20,15,10]\u003c/p\u003e\n\u003cp\u003e在样例二中,最终的数列为:[500,500]\u003c/p\u003e\n\u003cp\u003e在样例三中,无解\u003c/p\u003e\n\u003cp\u003e在样例四中,最终的数列为:[0,3,6,9,12]\u003c/p\u003e"}}]}