#include #include #include using namespace std; int main() { int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } long long ans = 1e18; for (int ii = 0; ii < n; ii++) { long long ll = 0; long long rr = 0; long long tt = 0; for (int i = 0; i < n; i++) { long long y = a[i]; long long x = i - ii; long long yy = y + x; long long xx = y - x; ll = min(ll, xx); rr = max(rr, xx); tt = max(tt, yy); } for (int jj = 0; jj < 2; jj++) { if (rr % 2 == 0) { ans = min(ans, rr / 2 + (tt + 1) / 2 + (rr - ll + 1) / 2); } else { ans = min(ans, rr / 2 + tt / 2 + (rr - ll + 1) / 2); } swap(ll, rr); ll *= -1; rr *= -1; } } cout << ans << endl; }