#include #define rep(i,a,b) for(int i=int(a);i> N; vector V(210 + N); rep(i,0,N)cin >> V[i]; int sum = 0,mini = INF; rep(i,0,N)sum += V[i]; //i := 最大値がiとなるピラミッド列 for(int i = 1;i * i <= sum;i++){ int dif = 0,use = 0; rep(k,0,i * 2 - 1){ int num = i - abs(i - k - 1); dif += max(V[k] - num , 0); use += V[k]; } dif += sum - use; mini = min(mini, dif); //cout << "i:" << i << " " << mini << endl; } cout << mini << endl; }