//int n;
//bool solve(vi arr, int mid){
//	if(mid == 1)
//		return arr.size() == 1;
//	vpii coll,fin;
//	for(auto cur : arr){
//		if(coll.empty() || coll.back().first != cur)
//			coll.pb(mp(cur,1));
//		else
//			coll.back().second++;
//	}
//	for(auto cur : coll){
//		if(fin.empty() || fin.back().first < cur.first)
//			fin.pb(cur);
//		else{
//			while(fin.back().first > cur.first){
//				if(fin.back().second < mid)
//					fin.pop_back();
//				else{
//					fin.back().second /= mid;
//					fin.back().first--;
//					if(fin.size() >= 2 && fin[sz(fin)-2].first == fin.back().first){
//						int tmp = fin.back().second;
//						fin.pop_back();
//						fin.back().second += tmp;
//					}
//				}
//			}
//			if(fin.back().first == cur.first)
//				fin.back().second += cur.second;
//			else
//				fin.pb(cur);
//		}
//	}
//	//watch(mid);
//	//watch(fin);
//	while(fin.back().first != 1){
//		fin.back().second /= mid;
//		fin.back().first--;
//		if(fin.back().second <= 0){
//			fin.pop_back();
//			continue;
//		}
//		if(fin.size() >= 2 && fin[sz(fin)-2].first == fin.back().first){
//			int tmp = fin.back().second;
//			fin.pop_back();
//			fin.back().second += tmp;
//		}
//	}
//	int total = 0;
//	//watch(fin);
//	for(auto cur : fin)
//		if(cur.first == 1)
//			total += cur.second;
//	return total <= mid;
//}
//void _(){
//	cin >> n;
//	vi arr(n);
//	cin >> arr;
//	vector<int> brr;
//	if(arr[0] != 1){
//		arr.insert(arr.begin(),1);
//		++n;
//	}
//	for(int i = 0; i < n; ++i){
//		if(i == 0 || arr[i] <= arr[i-1])
//			brr.push_back(arr[i]);
//	}
//	n = sz(brr);
//	//watch(brr);
//	int lo = 0, hi = 1e9, mid;
//	while(lo < hi){
//		mid = (lo+hi)/2;
//		if(solve(brr,mid))
//			hi = mid;
//		else
//			lo = mid+1;
//	}
//	print(lo);
//}
//
//
// ================================================ 
// ^^^	ABOVE is what I wrote in my editor	^^^
// ------------------------------------------------ 
// vvv	BELOW is automatically generated 	vvv
// ================================================ 
#include <set>
#include <iomanip>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define pb push_back 
#define mp make_pair 
#define all(v) (v).begin(),(v).end()
#define sz(v) ll(v.size())
#define watch(x) cout << (#x) << " = " << x << '\n'
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
template<typename IT>
ostream &print(IT b, IT e, string sep = " ", ostream &stream = cout){
    for(IT it = b; it != e; ++it){
        stream << *it;
        if(it+1 != e) stream << sep;
    } 
    return stream;
}
template<typename IT> istream &read(IT b, IT e, istream &stream = cin){
    for(IT it = b; it != e; ++it)
        stream >> *it; 
    return stream;
}
template<typename T> ostream &operator<<(ostream &stream, vector<T> &t){
    return print(all(t)," ",stream);
}
template<typename T> ostream &operator<<(ostream &stream, vector<T> &&t){
    return print(all(t)," ",stream);
}
template<typename T> istream &operator>>(istream &stream, vector<T> &t){
    return read(all(t),stream);
}
template<typename F, typename S> ostream &operator<<(ostream &stream, const pair<F,S> t){
    return stream << t.first << ' ' << t.second;
}
template<typename F, typename S> istream &operator>>(istream &stream, pair<F,S> &t){
    return stream >> t.first >> t.second;
}
template <typename T> 
void print(T x, string end = "\n"){
    cout << x << end;
}
template <typename t> 
void print(vector<t> arr,string sep=" "){
    if(arr.empty()){
        return;
    }
    print(arr.begin(),arr.end(),sep);
    cout << '\n';
}
template <typename T> 
void print(vector<vector<T> > arr){
    for(int i = 0; i < sz(arr); ++i){
        cout << "[" << arr[i] << "]";
        if(i+1 < sz(arr))
            cout << ", ";
    }
    cout << '\n';
}
template<typename T>
T _();
const ll MOD = 1e9+7;
template<typename T>
vector<T> operator+(const vector<T> &lhs, const vector<T> &rhs){
    vector<T> ans(lhs);
    assert(ans.size() == rhs.size());
    for(int i = 0; i < rhs.size(); ++i)
        ans[i] += rhs[i];
    return ans;
}
template<typename T>
vector<T> operator+=(vector<T> &lhs, const vector<T> &rhs){
    return lhs = lhs+rhs;
}
template<typename T>
vector<T> operator-(const vector<T> lhs, const vector<T> rhs){
    vector<T> ans(all(lhs));
    assert(ans.size() == rhs.size());
    for(int i = 0; i < rhs.size(); ++i)
        ans[i] -= rhs[i];
    return ans;
}
template<typename T>
vector<T> operator-=(vector<T> &lhs, const vector<T> &rhs){
    return lhs = lhs-rhs;
}
template<typename T>
vector<T> append(vector<T> &lhs, const vector<T> rhs){
    lhs.insert(lhs.end(),all(rhs));
    return lhs;
}
template<typename T>
T max(const vector<T> arr){
    assert(!arr.empty());
    T ans = arr[0];
    for(auto &cur : arr)
        ans = max(ans,cur);
    return ans;
}
template<typename T>
T max(const set<T> s){
    assert(!s.empty());
    return *--s.end();
}
template<typename T, typename G>
vector<T> set_max(vector<T> &base, const vector<G> &comp){
    assert(base.size() == comp.size());
    for(int i = 0; i < (int)comp.size(); ++i)
        base[i] = max(base[i],comp[i]);
    return base;
}
int n;
bool solve(vi arr, int mid){
	if(mid == 1)
		return arr.size() == 1;
	vpii coll,fin;
	for(auto cur : arr){
		if(coll.empty() || coll.back().first != cur)
			coll.pb(mp(cur,1));
		else
			coll.back().second++;
	}
	for(auto cur : coll){
		if(fin.empty() || fin.back().first < cur.first)
			fin.pb(cur);
		else{
			while(fin.back().first > cur.first){
				if(fin.back().second < mid)
					fin.pop_back();
				else{
					fin.back().second /= mid;
					fin.back().first--;
					if(fin.size() >= 2 && fin[sz(fin)-2].first == fin.back().first){
						int tmp = fin.back().second;
						fin.pop_back();
						fin.back().second += tmp;
					}
				}
			}
			if(fin.back().first == cur.first)
				fin.back().second += cur.second;
			else
				fin.pb(cur);
		}
	}
	//watch(mid);
	//watch(fin);
	while(fin.back().first != 1){
		fin.back().second /= mid;
		fin.back().first--;
		if(fin.back().second <= 0){
			fin.pop_back();
			continue;
		}
		if(fin.size() >= 2 && fin[sz(fin)-2].first == fin.back().first){
			int tmp = fin.back().second;
			fin.pop_back();
			fin.back().second += tmp;
		}
	}
	int total = 0;
	//watch(fin);
	for(auto cur : fin)
		if(cur.first == 1)
			total += cur.second;
	return total <= mid;
}
void _(){
	cin >> n;
	vi arr(n);
	cin >> arr;
	vector<int> brr;
	if(arr[0] != 1){
		arr.insert(arr.begin(),1);
		++n;
	}
	for(int i = 0; i < n; ++i){
		if(i == 0 || arr[i] <= arr[i-1])
			brr.push_back(arr[i]);
	}
	n = sz(brr);
	//watch(brr);
	int lo = 0, hi = 1e9, mid;
	while(lo < hi){
		mid = (lo+hi)/2;
		if(solve(brr,mid))
			hi = mid;
		else
			lo = mid+1;
	}
	print(lo);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(15);
    _();
}


Measured memory_bytes: 8224