#include using namespace std; #define rep(i,a,b) for(int i=a;i> n; vector arr; rep(i,0,n){ int t; cin >> t; arr.push_back(t); }; double sumx = (n)*(n-1)/2; double sumy = accumulate(arr.begin(),arr.end(),0); double sumx2 = 0; rep(i,0,n) sumx2 += pow(i,2); double sumxy = 0; rep(i,0,n) sumxy += arr[i] * i; double a = (n * sumxy - sumx * sumy)/(n * sumx2 - sumx * sumx); double b = (sumx2 * sumy - sumxy * sumx)/(n * sumx2 - sumx * sumx); printf("%.8f %.8f\n", b, a); double ans = 0; rep(i,0,n) ans += pow((arr[i]-(a*i+b)),2); printf("%.8f\n", ans); }