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
def solve(aaa):
    l = 1
    r = 200000
    while l < r:
        m = (l + r) // 2
        if check(m, aaa):
            r = m
        else:
            l = m + 1
    return r


def check(d, aaa):
    if d == 1:
        return all(a1 < a2 for a1, a2 in zip(aaa, aaa[1:]))
    l = 0
    word = [[0, 0]]
    for a in aaa:
        if l >= a:
            if not carry(d, word, a):
                return False
        l = a
    return True


def carry(d, word, i):
    while word[-1][0] > i:
        word.pop()
    while word[-1] == [i, d]:
        word.pop()
        i -= 1
    if i == 0:
        return False
    if word[-1][0] == i:
        word[-1][1] += 1
    else:
        word.append([i, 2])
    return True


n = int(input())
aaa = list(map(int, input().split()))
print(solve(aaa))
