#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); using ld = long double; int N; cin >> N; vector> p(N); rep(i,N) { p[i].first = i; cin >> p[i].second; } ld X = 0, Y = 0, XY = 0, XX = 0; for(auto [x, y] : p) { X += x; Y += y; XY += x * y; XX += x * x; } ld a = (N * XY - X * Y) / (N * XX - X * X); ld b = (XX * Y - XY * X) / (N * XX - X * X); ld e = 0; rep(i,N) { auto [x, y] = p[i]; ld y2 = a * i + b; e += (y - y2) * (y - y2); } cout << fixed << setprecision(20) << b << " " << a << "\n" << e << endl; }