#include <bits/stdc++.h>
using namespace std;
vector<int> build_holy_array(vector<int> base) {
  int n = base.size();
  vector<int> res(n);
  int i = 0;
  while (i < n && base[i] >= i + 1) {
    res[0]++;
    i++;
  }
  for (int i = 1; i < n; i++) {
    res[i] = max(res[i - 1] - 1, 0);
    int ind = i + res[i];
    while (ind < n && base[ind] >= (ind - i) + 1) {
      res[i]++;
      ind++;
    }
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b = build_holy_array(a);
  reverse(a.begin(), a.end());
  vector<int> c = build_holy_array(a);
  reverse(c.begin(), c.end());
  reverse(a.begin(), a.end());
  int res = 0;
  for (int i = 0; i < n; i++) {
    int l = 0, r = b[i] + 1;
    while (l + 1 < r) {
      int m = (l + r) / 2;
      if (m > 0 && i + (m - 1) * 2 < n && c[i + (m - 1) * 2] >= m)
        l = m;
      else
        r = m;
    }
    res = max(res, l);
  }
  cout << res << endl;
  return 0;
}
