#include #include #include #include #include #include #include #include #define rep(x,to) for(int (x)=0;(x)<(to);(x)++) #define repf(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++) using namespace std; typedef long long ll; int main() { int n; cin >> n; vector a(n); rep(i,n) cin >> a[i]; int res = 1<<29; int lm = (int)sqrt(accumulate(a.begin(),a.end(),0)); for(;lm;lm--){ int ki=0; vector oo(220,0); oo[0]=1; repf(i,1,2*lm-1) oo[i] = i oo[i]) ki += a[i] - oo[i]; } res = min(res, ki); } cout << res << endl; return 0; }