The input size for this problem is huge, you may refer to the code in notes for faster input.
Be aware of the error caused by using floating point numbers.
Link has an array

of length

. NIO wants it to be an arithmetic progression(i.e.,
d)
).
Link can arbitrarily modify the value of

. For each

, he can modify at most once. Suppose Link changed the value from

to

, the cost is
%5E2)
.
What is the minimum cost to make

an arithmetic progression?
输入描述:
Each test contains multiple test cases. The first line contains the number of test cases
(
). Description of the test cases follows.
The first line contains an integer
(
).
The second line contains
integers
(
).
It is guaranteed that the sum of
over all test cases does not exceed
.
输出描述:
For each case, output your answer in one line.
Your answer is considered correct if its absolute or relative error does not exceed
.
Formally, let your answer be
, and the jury's answer be
. Your answer is accepted if and only if
.
示例1
输入
复制
3
3
-1 0 1
3
0 0 1
13
1 1 4 5 1 4 1 9 1 9 8 1 0
输出
复制
0.000000000000000
0.166666666666667
129.225274725274716
说明
In the second example, you may change
to
to minimize the cost.
备注:
Reference code:
#include <cstdio>
#include <cctype>
namespace GTI
{
char gc(void)
{
const int S = 1 << 16;
static char buf[S], *s = buf, *t = buf;
if (s == t) t = buf + fread(s = buf, 1, S, stdin);
if (s == t) return EOF;
return *s++;
}
int gti(void)
{
int a = 0, b = 1, c = gc();
for (; !isdigit(c); c = gc()) b ^= (c == '-');
for (; isdigit(c); c = gc()) a = a * 10 + c - '0';
return b ? a : -a;
}
}
using GTI::gti;
int main(){
// Use gti() to get next int from standard input.
}