#include using namespace std; int main() { int N, A[110]; cin >> N; for (int i = 0; i < N; i++) { cin >> A[i]; } int SUM = 0; for (int i = 0; i < N; i++) { SUM += A[i]; } int ans = 10000000; for (int i = 0; (i + 1) * (i + 1) <= SUM; i++) { int cost = 0; for (int j = 0; j < N; j++) { if (j <= i) cost += max(0, A[j] - j - 1); else if (j <= i * 2) cost += max(0, A[j] - (i * 2 + 1 - j)); else cost += A[j]; } ans = min(ans, cost); } cout << ans << endl; }