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
import sys
from bisect import bisect as br
readline = sys.stdin.readline

'''
def debug(rl, s):
    PAA = []
    pre = 0
    for f, g in zip(rl, s):
        if f-pre:
            PAA.extend([g]*(f-pre))
        pre = f
    print('d',med,  ''.join(map(str, PAA)))
'''
def check(x):
    s = [0, 0]
    rl = [0, A[0]]
    for a in A[1:]:
        if rl[-1] < a:
            s.append(0)
            rl.append(a)
            continue
        idx = br(rl, a-1)
        s = s[:idx+1]
        rl = rl[:idx] + [a]
        while idx and s[idx] == x-1:
            s.pop()
            rl.pop()
            idx -= 1
        if idx == 0:
            return False
        if rl[-2] == rl[-1] - 1:
            s[-1] += 1
        else:
            rl[-1] -= 1
            rl.append(rl[-1]+1)
            s.append(s[-1]+1)
        if rl[-1] != a:
            rl.append(a)
            s.append(0)
        
    return True

N = int(readline())
A = list(map(int, readline().split()))

ok = N
ng = 0
while abs(ok - ng) > 1:
    med = (ok+ng)//2
    if check(med):
        ok = med
    else:
        ng = med
print(ok)