#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const pid_t pid = getpid();
// Problem Specific Parameter:

const int limit = 200010;
vector<int> a;

#define error(args...) { vector<string> _debug = split(#args, ',');err(begin(_debug), args);}

vector<string> split(const string& s, char c){
	vector<string> v;stringstream ss(s);string x;
	while (getline(ss, x, c)) v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {cerr << endl;}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a,Args... args){
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << " ",err(++it, args...);
}

template <int depth>  struct Segment_tree {
	const static int h = depth;
	const static int n = 1 << h;

	using T = long long;
	T data[2 * n], lazy[2 * n];
	const T out = -1LL;

	inline T vmerge(T l, T r) {return max(l, r);}

	void init() {
		fill_n(data, 2 * n, out);
		fill_n(lazy, 2 * n, out);
	}

		// lazy_evaluation
	void apply(T v, int p, int l, int r) {
		data[p] = v;
		lazy[p] = v;
	}

	void push(int p, int l, int r) {
		const int m = (l + r) / 2;
		if (lazy[p] == out) return;
		apply(lazy[p], 2 * p + 1, l, m);
		apply(lazy[p], 2 * p + 2, m, r);
		lazy[p] = out;
	}

	void range_update(int a, int b, T x, int k = 0, int l = 0, int r = n) {
		if (r <= a or b <= l) return;
		if (a <= l and r <= b) return apply(x, k, l, r);
		push(k, l, r);
		const int m = (l + r) / 2;
		range_update(a, b, x, k * 2 + 1, l, m);
		range_update(a, b, x, k * 2 + 2, m, r);
		data[k] = vmerge(data[k * 2 + 1], data[k * 2 + 2]);
	}

	T range_query(int a, int b, int k = 0, int l = 0, int r = n) {
		if (r <= a or b <= l) return out;
		if (a <= l and r <= b) return data[k];
		push(k, l, r);
		const int m = (l + r) / 2;
		T vl = range_query(a, b, k * 2 + 1, l, m);
		T vr = range_query(a, b, k * 2 + 2, m, r);
		return vmerge(vl, vr);
	}
};

Segment_tree<18> seg;


bool check(int num){
	const int n = a.size();
	seg.init();
	seg.range_update(0,seg.n,0);
	rep(i,1,n){
		const int bn = a[i-1];
		const int an = a[i];
		if(bn < an) continue;
		if(limit < an) continue;

		int ai = an;
		int val = seg.range_query(ai, ai + 1) + 1;

		while(ai > 0 and val == num){
			ai--;
			val = seg.range_query(ai, ai + 1) + 1;
		}

		if(ai == 0) return false;
		seg.range_update(ai,ai+1,val);
		seg.range_update(ai + 1, seg.n,0);		
	}
	return true;
}


int main(void){
	int n;
	cin >> n;
	a = vector<int>(n);
	rep(i,n) cin >> a[i];

	int ng = 0, ok = n;
	while(ok - ng > 1){
		const int mid = (ok + ng) / 2;
		if(check(mid))
			ok = mid;
		else
			ng = mid;
	}

	
	cout << ok << endl;

	return 0;
}

Measured memory_bytes: 9216