#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
typedef long long ll;
const int MAX_N=2e5;
int N;
ll A[MAX_N];
bool C(ll x){
	map<int,ll> mp;
	REP(i,N-1){
		if (A[i]>=A[i+1]){
			auto ite=mp.lower_bound(A[i+1]);
			while(ite!=mp.end()){
				auto ite2=ite;
				ite2++;
				mp.erase(ite);
				ite=ite2;
			}
			ll inx=A[i+1]-1;
			do{
				if (mp[inx]!=x-1){
					mp[inx]++;
					break;
				}else{
					mp[inx]=0;
					inx--;
				}
			}while(inx>=0);
			if (inx<0){
				return false;
			}
		}
	}
	return true;
}
int main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	bool flg=true;
	REP(i,N-1){
		if (A[i]>=A[i+1]){
			flg=false;
		}
	}
	if (flg){
		cout<<1<<endl;
	}else{
		ll lb=1,ub=N;
		while(ub-lb>1){
			ll mid=(lb+ub)>>1;
			if (C(mid)){
				ub=mid;
			}else{
				lb=mid;
			}
		}
		cout<<ub<<endl;
	}
	return 0;
}