#include<algorithm>
#include<iostream>
#include<map>
#include<vector>

bool enough(const std::vector<int>& a, int k) {
  std::map<int, int> mp;
  for(int i = 1; i < a.size(); i++){
    if (a[i-1] < a[i]) continue;
    if (k == 1) return false;

    // case: a[i-1] >= a[i]
    int v = a[i];
    mp.erase(mp.upper_bound(v), mp.end());
    while(mp[v] == k-1) {
      --v;
      if (v == 0) return false;
    }

    ++mp[v];
    mp.erase(mp.upper_bound(v), mp.end());
  }
  return true;
}

int main(){
  int n; std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }

  int l = 0, r = n;
  while(r - l > 1) {
    int mid = (r + l) / 2;
    if (enough(a, mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }

  std::cout << r << std::endl;
  return 0;
}
