#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) const int INF = 1e6; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector a(256); REP (i, n) cin >> a[i]; int sum = accumulate(a.begin(), a.end(), 0); int ret = INF; vector b(256); for (int l = 1; l < 256; l += 2) { fill(b.begin(), b.end(), 0); b[l/2] = l/2 + 1; for (int i = 1; i <= l/2; i++) b[l/2-i] = b[l/2+i] = l/2+1-i; if ((l+1)*(l+1)/4 > sum) break; int tmp = 0; REP (i, 256) if (a[i] > b[i]) tmp += a[i] - b[i]; ret = min(ret, tmp); } cout << ret << endl; return 0; }