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
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
# import random

# N = 10**5
# A = [random.randrange(1,10**9+1) for _ in range(N)]

# import time

def main():
    l = 0
    r = N
    while r-l > 1:
        m = (r+l)//2
        ok = True
        if m == 1:
            pre = -1
            for a in A:
                if pre >= a:
                    ok = False
                    break
                pre = a
        else:
            dp = {}
            needreset = 10**15
            exception = set()
            pre = -1
            for a in A:
                ind = a
                for _ in range(40):
                    # 修正
                    if needreset >= ind or ind in exception:
                        if not ind in dp:
                            dp[ind] = 0 if pre < a else 1
                    else:
                        dp[ind] = 0 if pre < a else 1
                        exception.add(ind)
                    # たす
                    if dp[ind] < m:
                        dp[ind] += 1
                        break
                    elif ind == 1:
                        ok = False
                        break
                    else:
                        # 繰り上がり
                        dp[ind] = 1
                        ind -= 1
                if not ok: break
                # 更新
                if pre > a:
                    needreset = a
                    exception = set()
                pre = a

        if ok:
            r = m
        else:
            l = m

    print(r)


if __name__ == "__main__":
    #dt = time.time()
    main()
    #print(time.time()-dt)
