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<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=200200,INF=1000010000;
int n,L,R,t,a[N];
struct ele{
	int l,r,w;
	ele(int _l=0,int _r=0,int _w=0){l=_l,r=_r,w=_w;}
}s[N];
bool chk(int S){
	int x=0,t=0,w,y;
	FOR(i,1,n){
		if(a[i]>x){s[++t]=ele(x+1,a[i]);x=a[i];continue;}
		x=a[i];
		while(s[t].l>x) t--;
		s[t].r=x;y=x+1;
		while(t && s[t].w==S-1) y=s[t--].l;
		if(!t) return 0;w=s[t].w;
		s[t].l<s[t].r?s[t].r--:t--;
		s[++t]=ele(y-1,y-1,w+1);
		if(y<=x) s[++t]=ele(y,x,0);
	}
	return 1;
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&n);
	FOR(i,1,n) scanf("%d",&a[i]);
	L=1;R=INF;
	while(L<R){
		int md=(L+R)>>1;
		chk(md)?R=md:L=md+1; 
	}
	cout<<L<<"\n";
}