#include <stdio.h>
#include <iostream>
using namespace std;
const int N=200010;
struct A{
	int l,r,v;
}s[N];
int a[N];
int n;
bool check(int ans){
	int i,j,k,len=0;
	for(i=1;i<=n;i++){
		if(i==1){
			s[++len]=(A){1,a[i],1};
		}
		else{
			if(a[i]>a[i-1]) s[++len]=(A){a[i-1]+1,a[i],1};
			else{
				while(s[len].l>a[i]) len--;
				s[len].r=a[i];
				for(j=len;j>=1&&s[j].v==ans;j--);
				if(j==0) return false;
				if(s[j].r==s[j].l) s[j].v++;
				else{
					s[j+1]=(A){s[j].r,s[j].r,s[j].v+1};
					s[j++].r--;
				}
				if(s[j].r<a[i]) s[len=j+1]=(A){s[j].r+1,a[i],1};
				else len=j;
			}
		}
	}
	return true;
}
int main(){
	int lb,rb,mid,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&a[i]);
	lb=0;rb=n;
	while(rb-lb>1){
		mid=lb+rb>>1;
		if(check(mid)) rb=mid;
		else lb=mid;
	}
	printf("%d",rb);
	return 0;
}
