#include<iostream>
#include<map>
#define lol(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;
#define N 200010
ll n,a[N];
bool $(ll k){
    map<ll,ll> mas;
    mas.clear();
    lol(i,n-1){
	if(a[i]<a[i+1])continue;
	mas[a[i+1]]++;
	for(ll j=a[i+1];j>0;j--){
	    if(mas[j]==k)mas[j]=0,mas[j-1]++;
	    else break;
	}
	if(mas[0]>0)return 0;
	while(mas.size()){
	    auto it=--mas.end();
	    if(not(it->first > a[i+1]))break;
	    mas.erase(it);
	}
    }
    return 1;
}
int main(){
    cin>>n;
    lol(i,n)cin>>a[i];
    bool tancho=1;
    lol(i,n-1)if(not(a[i]<a[i+1]))tancho=0;
    if(tancho)return cout<<1<<endl,0;
    ll l=1,r=N,m;
    for(;l<r-1;){
	m=(l+r)/2;
	if($(m))r=m;
	else l=m;
    }
    cout<<r<<endl;
    return 0;
}
