#include #include #include using namespace std; using ll = long long; using vi = vector; #define in(v) v; cin >> v; void ins() {} templatevoid ins(T& v,Rest&... rest){cin>>v;ins(rest...);} #define rep(i,n) for(int i=0,_i=(n);i<_i;++i) int main() { int N; ins(N); vi A(N); rep(i, N) { cin >> A[i]; } cout << fixed << setprecision(15); ll diff = 0; rep(i, N-1) diff += A[i+1] - A[i]; ll B = 0, B2 = 0; rep(i, N) { B += A[i] * (N-1) - diff * i; B2 += A[i] * N - diff * i; } double b = 1.0 * B / (N-1) / N, d = 1.0 * diff / (N-1); double b2 = 1.0 * B / N / (N+1), d2 = 1.0 * diff / N; double ans = 0, ans2 = 0; rep(i, N) { ans += 1.0 * (A[i] - b - d * i) * (A[i] - b - d * i); ans2 += 1.0 * (A[i] - b2 - d2 * i) * (A[i] - b2 - d2 * i); } if (ans < ans2) cout << b << " " << d << endl << ans << endl; else cout << b2 << " " << d2 << endl << ans2 << endl; return 0; }