#include using namespace std; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define repi(i,a,b) for(int i=int(a);i<(int)(b);i++) #define all(x) (x).begin(),(x).end() #define foreach(u,v) for(auto (u) : (v)) #define pb push_back #define mp make_pair #define mt make_tuple typedef long long ll; typedef pair pii; typedef vector vi; typedef vector vvi; typedef pair pll; typedef vector vl; const int inf = 1e9; const ll linf = 1e18; const ll mod = 1e9 + 7; const double eps = 1e-9; int main() { int n; cin >> n; vi a(n); rep(i, n){ cin >> a[i]; } double x = 0, y = 0, xy = 0, xx = 0; rep(i, n){ xy += i*a[i]; x += i; y += a[i]; xx += i*i; } double ans1 = (xx*y-xy*x)/(n*xx-x*x); double ans2 = (n*xy-x*y)/(n*xx-x*x); double cost = 0; rep(i, n){ double f = ans2*i + ans1; cost += (a[i]-f)*(a[i]-f); } printf("%.9f %.9f\n", ans1, ans2); printf("%.9f\n", cost); return 0; }