output_description: Print the minimum possible number of different characters contained in the
  strings.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 ... A_N
attempt: N = int(input())
  A = [int(a) for a in input().split()]
  
  l = 0
  r = 2 * 10**5
  
  m = 2
  while r - l >= 2:
      m = l + (r - l) // 2
      X = {}
      for i in range(1, N):
          try:
              if A[i] <= A[i - 1]:
                  if A[i] < A[i - 1]:
                      for j in X:
                          if j > A[i]:
                              X[j] = 0
                              # del X[j]
                  if A[i] in X:
                      X[A[i]] += 1
                      k = A[i]
                      while k in X and X[k] >= m:
                          X[k] = 0
                          if k - 1 in X:
                              X[k - 1] += 1
                          else:
                              X[k - 1] = 1
                          k -= 1
                          if k <= 0:
                              raise Exception
                  else:
                      X[A[i]] = 1
          except:
              # print(m, "Err")
              l = m
              break
          # print(i, X)
      else:
          # print(m, "OK")
          r = m
  # print(A)
  # print(X)
  print(r + 1)
  
problem_description: Statement
  
  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?
samples: [{"input": "3\n    3 2 1", "output": "2\n    \n\nThe number of different characters contained in S_1,S_2,...,S_N would be 3\nwhen, for example, S_1=`abc`, S_2=`bb` and S_3=`c`.\n\nHowever, if we choose the strings properly, the number of different characters\ncan be 2.\n\n* * *"}, {"input": "5\n    2 3 2 1 2", "output": "2"}]