#include using namespace std; #define ll long long #define FOR(i,n,m) for(int i=(n);i<(m);i++) #define REP(i,n) FOR(i,0,n) #define REPR(i,n) for(int i=(n);i>=0;i--) #define all(vec) vec.begin(),vec.end() using vi=vector; using vvi=vector; using vl=vector; using vvl=vector; using P=pair; using PP=pair; using Pl=pair; using PPl=pair; using vs=vector; #define fi first #define se second #define pb push_back templatebool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;} const ll MOD=1000000007LL; const int INF=1<<30; const ll LINF=1LL<<60; using dP=pair; double g(const vector& vec,double a,double b){ double res=0; REP(i,vec.size()){ res+=pow(vec[i]-(a*i+b),2); } return res; } const double lb=-1e8,ub=1e8; const int N=1000; dP f(const vector& vec,double x){ double l=lb,r=ub; REP(_,N){ double a=(l*2+r)/3; double b=(l+r*2)/3; double p=g(vec,x,a); double q=g(vec,x,b); if(p>q){ l=a; }else{ r=b; } } return make_pair(g(vec,x,l),l); } int main(){ int n; cin>>n; vector vec(n); REP(i,n){ cin>>vec[i]; } double l=lb,r=ub; REP(_,N){ double a=(l*2+r)/3; double b=(l+r*2)/3; dP p=f(vec,a); dP q=f(vec,b); if(p>q){ l=a; }else{ r=b; } } dP ans=f(vec,l); cout<