#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("Yes");}else{puts("No");} #define MAX_N 200005 int main() { int n; cin >> n; int a[n]; int sum = 0; rep(i,n){ cin >> a[i]; sum += a[i]; } int ans = 1001001001; srep(i,1,1000){ if(i % 2 == 0)continue; int tmp = (i/2+1) * (i/2+1); if(sum < tmp)break; int cnt = 0; int b[1010] = {}; rep(j,i/2+1){ b[j] = j + 1; b[i-1-j] = j + 1; } rep(j,n){ cnt += max(0, a[j] - b[j]); } ans = min(ans, cnt); /* rep(j,n)cout << b[j] << ' '; cout << endl << cnt << endl; */ } cout << ans << endl; return 0; }