#include using namespace std; using int64 = long long; int main() { int N, A[1000]; cin >> N; for(int i = 0; i < N; i++) cin >> A[i]; tuple< double, double, double > ret(1e30, 1e30, 1e30); double left = -400000, right = 400000; auto check2 = [&](double real_d) { auto check = [&](double a) { double b = a; double cost = 0.0; for(int j = 0; j < N; j++) { cost += (A[j] - a) * (A[j] - a); a += real_d; } ret = min(ret, make_tuple(cost, b, real_d)); return cost; }; double low = -400000, high = 400000; for(int j = 0; j < 300; j++) { double latte = (low * 2 + high) / 3; double malta = (low + high * 2) / 3; if(check(latte) < check(malta)) high = malta; else low = latte; } return check(low); }; for(int i = 0; i < 300; i++) { double aa = (left * 2 + right) / 3; double bb = (left + right * 2) / 3; if(check2(aa) < check2(bb)) right = bb; else left = aa; } cout << fixed << setprecision(10) << get< 1 >(ret) << " " << get< 2 >(ret) << endl << get< 0 >(ret) << endl; }