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>
int N,A[200010];
int pos[400010],S[400010];
bool chk(int M){
	int tot=0;
	pos[0]=0;
	//printf("M=%d\n",M);
	for(int i=0;i<N;i++){
		if(A[i]>pos[tot]){
			S[tot]=1;
			pos[++tot]=A[i];
		}
		else{
			while(pos[tot]>A[i]){
				if(tot&&pos[tot-1]<A[i])pos[tot]=A[i];
				else--tot;
			}
			while(tot&&S[tot-1]==M)--tot;
			if(!tot)return 0;
			if(pos[tot]==pos[tot-1]+1)S[tot-1]++;
			else{
				pos[tot]--;
				S[tot]=S[tot-1]+1;
				pos[tot+1]=pos[tot]+1;
				tot++;
			}
			if(pos[tot]<A[i]){
				S[tot]=1;
				pos[++tot]=A[i];
			}
		}
		
		//for(int j=0;j<tot;j++)
		//	for(int k=pos[j];k<pos[j+1];k++)printf("%d",S[j]);puts("");
	}
	return 1;
}
int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%d",A+i);
	int left=0,right=N,mid;
	while(right-left>1)chk(mid=left+right>>1)?right=mid:left=mid;
	printf("%d\n",right);
}