#include <bits/stdc++.h>
const int INF = 2E9 + 1;
using namespace std;
vector<vector<pair<int, int>>> g;
vector<int> d;
void Dijkstra(int v) {
  d[v] = 0;
  set<pair<int, int>> st = {make_pair(d[v], v)};
  while (!st.empty()) {
    v = st.begin()->second;
    st.erase(st.begin());
    for (int i = (0); i < (g[v].size()); ++i) {
      int to = g[v][i].second;
      int dto = g[v][i].first;
      if (dto + d[v] < d[to]) {
        st.erase(make_pair(d[to], to));
        d[to] = dto + d[v];
        st.insert(make_pair(d[to], to));
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, h;
  cin >> n;
  d.resize(n + 3, INF);
  g.resize(n + 3);
  cin >> h;
  g[n + 2].emplace_back(make_pair(h, 1));
  for (int i = (2); i < (n + 1); ++i) {
    cin >> h;
    g[i - 1].emplace_back(make_pair(1, i));
    g[i].emplace_back(make_pair(1, i - 1));
    g[n + 2].emplace_back(make_pair(h, i));
  }
  g[n + 2].emplace_back(make_pair(0, 0));
  g[n + 2].emplace_back(make_pair(0, n + 1));
  g[0].emplace_back(make_pair(1, 1));
  g[n + 1].emplace_back(make_pair(1, n));
  Dijkstra(n + 2);
  int R = 0;
  for (int i = (1); i < (n + 1); ++i) {
    R = max(R, d[i]);
  }
  cout << R << endl;
  return 0;
}
