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
N = int(input())
A_raw = list(map(int, input().split()))

flg = 1
prev = 0
A = []
for i in range(N):
    if A_raw[i] <= prev:
        flg = 0
    prev = A_raw[i]
    if A_raw[i] <= 50:
        A.append(A_raw[i])

if flg:
    print(1)
    exit()

N = len(A)
if N <= 1:
    print(2)
    exit()

ok = N
ng = 1
mid = (ok + ng) // 2
while ok - ng > 1:
    ng_flg = 0
    word = [1] * A[0]
    for i in range(1, N):
        if A[i] > A[i-1]:
            word.extend([1] * (A[i] - A[i-1]))
        else:
            word_prev = word[:A[i]]
            k = A[i] - 1
            while True:
                if k == -1:
                    ng_flg = 1
                    break
                if word_prev[k] != mid:
                    word_prev[k] += 1
                    word = word_prev
                    break
                else:
                    word_prev[k] = 1
                    k -= 1
        if ng_flg == 1:
            break
    if not ng_flg:
        ok = mid
    else:
        ng = mid
    mid = (ok + ng) // 2

print(ok)
