#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 = 1000000; int main() { cin >> N; FOR(i,0,N - 1) { cin >> a[i]; total += a[i]; } int memo = 0; FOR(i,1,N) { memo += 2 * i -1; if(total < memo ) 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; }