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 <bits/stdc++.h>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
using namespace std;
typedef long long ll;
inline int read(){
	int n=0,f=1;char c;
	for(c=getchar();c!='-'&&(c<'0'||c>'9');c=getchar());
	if (c=='-') f=-1,c=getchar();
	for(;c>='0'&&c<='9';c=getchar()) n=(n<<3)+(n<<1)+(c&15);
	return n*f;
}
const int maxn=2e5+5;
int i,j,k,s,n,len,a[maxn];
map<int,int>p;
map<int,int>::iterator it;
int main(){
	n=read();
	fo(i,1,n) a[i]=read();
	int l=1,r=n;
	for(;l<r;){
		int m=(l+r)>>1;
		p.clear();
		len=0;
		for(i=1;i<=n;i++){
			int x=a[i];
			if (x>len){len=x;continue;}
			for(;;){
				it=p.end();
				if (it!=p.begin()) it--;else break;
				if (it->first>x) p.erase(it);else break;
			}
			if (m==1) break;
			p[x]++,len=x;
			for(;x&&p[x]==m;) p.erase(p.find(x)),p[--x]++;
			if (x<=0) break;
		}if (i>n) r=m;else l=m+1;
	}printf("%d\n",l);
}