#include using namespace std; #define FOR(i,s,e) for(int i = (s);i <=(e);i++) int total; int N; int a[100]; int result = 10000; int main() { cin >> N; FOR(i,0,N - 1) { cin >> a[i]; total += a[i]; } int memo = 0; FOR(i,1,N) { memo += i; if(total < memo || i > N / 2 + 1) break; int cou = 1; int temp = 0; FOR(j,0,i - 1) { if(cou < a[j]) temp += a[j] - cou; cou++; } cou = i - 1; FOR(j,i,i + i - 1) { if(cou < a[j]) temp += a[j] - cou; cou--; } FOR(j,i + i,N - 1) { temp += a[j]; } result = min(result,temp); } cout << result << endl; return 0; }