/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template <typename T>
    debugger &operator,(const T &v)
    {
        cerr << v << " ";
        return *this;
    }
} dbg;
const int MAXN = 300000;
LL a[MAXN + 10];
LL n;
LL K[MAXN + 10];
LL mi[1000],mimx;
struct Data
{
    LL l, r, v;
};
LL getMax(Data x, LL k)
{
	int len=x.r-x.l+1;
    if (len > mimx)
        return INT_MAX;
    return mi[len];
}
bool check(LL k)
{
    mi[0] = 1;
    for (int i = 1; i <= 40; ++i) {
        mi[i] = mi[i - 1] * k;
		if (mi[i]>INT_MAX) {
			mimx=i-1;
			break;
		}
    }
    vector<Data> q;
    q.push_back({ 1, a[1], 1 });
    for (int i = 2; i <= n; ++i) {
        if (a[i] == q.back().r) {
            q.back().v++;
            auto p = prev(q.end());
            while (getMax(*p, k) < p->v) {
                if (p == q.begin())
                    return false;
                p->v = 1;
                --p;
                p->v++;
            }
        } else if (a[i] > q.back().r) {
            q.push_back({ q.back().r + 1, a[i], 1 });
        } else {
            while (q.back().l > a[i])
                q.pop_back();
            LL v = q.back().v - 1;
            while (q.back().r > a[i]) {
                q.back().r--;
				if (v==0) break;
                v /= k;
            }
			q.back().r=a[i];
            q.back().v = v + 1;
            q.back().v++;
            auto p = prev(q.end());
            while (getMax(*p, k) < p->v) {
                if (p == q.begin())
                    return false;
                p->v = 1;
                --p;
                p->v++;
            }
        }
    }
    return true;
}
void solve()
{
    bool flag = true;
    for (int i = 2; i <= n; ++i) {
        if (a[i] <= a[i - 1]) {
            flag = false;
            break;
        }
    }
    if (flag) {
        puts("1");
        return;
    }
    int l = 2, r = n, ans = n;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (check(mid)) {
            r = mid - 1;
            ans = mid;
        } else {
            l = mid + 1;
        }
    }
    cout << ans << endl;
}
LL tong[MAXN + 10];
int main()
{
#ifdef WAAUTOMATON
    freopen("in.txt", "r", stdin);
#endif
    scanf("%lld", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
        tong[i] = a[i];
    }
    /*sort(tong+1,tong+1+n);
    int tcnt=unique(tong+1,tong+1+n)-tong-1;
    for(int i=1; i<=n; ++i) {
            a[i]=lower_bound(tong+1,tong+1+tcnt,a[i])-tong;
    }
    for(int i=1; i<=tcnt; ++i) {
            K[i]=tong[i]-tong[i-1];
    }*/
    solve();
    return 0;
}


Measured memory_bytes: 9016