import std.stdio, std.string, std.conv, std.algorithm, std.array;
alias L = long;
L n, a, k, f, m;
L[] A, U, V;

void main(){
	readf("%d\n", &n);
	A = readln.split.map!(to!L).array ~ 1;
	U = A.dup, V = A.dup;
	
	m = 1;
	while(n - m > 1){
		k = (m + n) / 2;
		//writeln("k:", k);
		L* u = &U[0], v = &V[0];
		*u = *v = 0;
		foreach(a; A){
			//writeln(" a:", a);
			if(*u < a) *++u = a, *++v = 1;
			else{
				while(*(u - 1) >= a){
					//writeln(" a:", a, " u:", *u);
					while(--*u >= *(u - 1) && *v) --*v, *v /= k;
					*(v - 1) += *v;
					--u, --v;
					//writeln(" a:", a, " U:", U, " V:", V);
				}
				if(*u > a){
					while(--*u >= a && *v) --*v, *v /= k;
					*u = a, ++*v;
					//writeln(" a:", a, " U:", U, " V:", V);
				}
				++f, ++*v;
			}
			//writeln(" a:", a, " U:", U, " V:", V);
		}
		//writeln(*v > k + 1);
		--f;
		(*v > k + 1? m : n) = k;
	}
	//writeln("f:", f);
	writeln(f? n: 1);
	
}