There are N strings arranged in a row. It is known that, for any two adjacent strings, the string to the left is lexicographically smaller than the string to the right. That is, S_1<S_2<...<S_N holds lexicographically, where S_i is the i-th string from the left.

At least how many different characters are contained in S_1,S_2,...,S_N, if the length of S_i is known to be A_i?

Constraints

* 1 \leq N \leq 2\times 10^5
* 1 \leq A_i \leq 10^9
* A_i is an integer.

Input

Input is given from Standard Input in the following format:


N
A_1 A_2 ... A_N


Output

Print the minimum possible number of different characters contained in the strings.

Examples

Input

3
3 2 1


Output

2


Input

5
2 3 2 1 2


Output

2
#include<cstdio>
const int N=2E5+10;
int n,h;
int a[N],p[N];
inline int gw(int x,int mod){
//	printf("%d %d\n",x,mod);
	if(!x) return 0;
	if(p[x]>=mod){
		p[x]-=mod;
		p[x-1]++;
		return gw(x-1,mod);
	}
	return 1;
}
inline int ck(int x){
	int now=0;
	for(int i=1;i<=n;i++) p[i]=0;
	for(int i=1;i<=n;i++){
		if(a[i]>n){
			now=a[i];
			continue;
		}
		if(a[i]>now){
			for(int i=1+now;i<=a[i];i++) p[i]=0;
			now=a[i];
		}else{
			p[now=a[i]]++;
			if(!gw(now,x)) return 0;
		}
	}
	return 1;
}
int main(){
//	freopen("C.in","r",stdin);
//	freopen("bl.out","w",stdout);
//	printf("1");return 0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	h=2;
	for(int i=3;i<=n;i++){
		if(a[i]>a[h]&&a[h]>a[h-1]) a[h]=a[i];
		else a[++h]=a[i];
	}
	n=h;if(n==2&&a[n]>a[n-1]){printf("1");return 0;}
	int l=2,r=n,res=1;
	while(l<=r){
		int mid=l+r>>1;
		if(ck(mid)){
			res=mid;
			r=mid-1;
		}else l=mid+1;
	}
	printf("%d\n",res);
	return 0;
}