#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); } ans = min(ans, (rr + tt + 1) / 2 + (rr - ll + 1) / 2); swap(ll, rr); ll *= -1; rr *= -1; ans = min(ans, (rr + tt + 1) / 2 + (rr - ll + 1) / 2); } cout << ans << endl; }