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 = [int(a) for a in input().split()]

def chk(k):
    if k == 1:
        for i in range(1, N):
            if A[i] <= A[i-1]: return 0
        return 1
    
    X = [(0, 0)]
    def add(x, y):
        if x <= 0: return 0
        if x > X[-1][0]:
            X.append((x, 0 if x == y else 1))
        elif x == X[-1][0]:
            if X[-1][1] + 1 < k:
                X[-1] = (X[-1][0], X[-1][1] + 1)
            else:
                if add(x-1, y) == 0: return 0
        else:
            while X[-1][0] > x:
                X.pop()
            if x > X[-1][0]:
                X.append((x, 1))
            elif x == X[-1][0]:
                if X[-1][1] + 1 < k:
                    X[-1] = (X[-1][0], X[-1][1] + 1)
                else:
                    if add(x-1, y) == 0: return 0
        if X[-1][0] < y: X.append((y, 0))
        return 1
    
    for a in A:
        if add(a, a) == 0: return 0
    return 1

l, r = 0, 1 << 18
while r - l > 1:
    m = (l + r) // 2
    if chk(m):
        r = m
    else:
        l = m

print(r)