#define _USE_MATH_DEFINES #define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" #define rep(i,n) for(int i = 0;i < n;i++) #define P(p) cout<<(p)<> ret; return ret; } ll gcd(ll a, ll b){ if (b > a)swap(a, b); if (b == 0)return a; else{ return gcd(b, a%b); } } void solve() { int v[1000]; int sum = 0; int n; cin >> n; fill(v, v + 1000, 0); for (int i = 1; i <= n;i++){ cin >> v[i]; sum += v[i]; } int top; int s = 1; if (s == sum){ P(1); return; } else{ for (int i = 1;; i++){ if (s + 2 * i + 1 <= sum){ top = i + 1; s += 2 * i + 1; } else{ break; } } } int height[10000]; fill(height, height + 10000, 0); for (int i = 1; i <= top;i++){ height[i] = i; height[i + (top - i) * 2] = i; } int need = 0; int left = 0; for (int i = 1; i <= n; i++){ int gap = v[i] - height[i]; if (gap < 0){ need += gap; } else{ left += gap; } } P(left); } int main() { solve(); return 0; }