#include #define FOR(i,a,b) for(int i = (a); i < (b); ++i) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) for(int i = (n) - 1; (i) >= 0; --i) #define SZ(n) (int)(n).size() #define ALL(n) (n).begin(), (n).end() #define MOD 1000007 #define INF 100000000 using namespace std; typedef long long LL; typedef vector VI; typedef pair PI; int main() { int n; int a[202] = {}; cin >> n; int sum = 0; REP(i, n) { cin >> a[i]; sum += a[i]; } int k = 1; int t = sum; while ((t -= k) >= 0) { k += 2; } int na[202] = {}; t = 0; REP(i, (k - 1) / 2) { na[i] = na[k - i - 3] = i + 1; t += na[i]; } int ans = sum; REP(i, k) { ans -= min(a[i], na[i]); } cout << ans << endl; return 0; }