#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define rep(i, N) for (int i = 0; i < N; i++) #define pb push_back typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair i_ll; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int v; ll w; }; const int MOD = 1000000007; const int _MOD = 1000000009; double EPS = 1e-10; const ll INF = LLONG_MAX / 10; int main() { int N; cin >> N; vector a(N); rep(i, N) cin >> a[i]; if (N == 1) { cout << a[0] << endl; return 0; } int lb = -1, ub = 1010000000; while (ub - lb > 1) { int mid = (lb + ub) / 2; bool ok = false; rep(i0, N) for (int d0 = -1; d0 <= 1; d0 += 2) { vector b(N, INT_MIN); int i = i0, d = d0; rep(t, N * 2) { if (b[i] == INT_MIN) b[i] = mid - t; if (i + d < 0 || i + d >= N) d *= -1; i += d; } bool unko = false; rep(i, N) if (b[i] < a[i]) unko = true; if (!unko) ok = true; } if (ok) ub = mid; else lb = mid; } cout << ub << endl; }