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(_) for _ in input().split() if int(_) < 19 else 18]
  N = len(A)
  for _ in range(3):
      flag = True
      B = [A[0]]
      for i in range(N - 1):
          if A[i] >= A[i + 1]:
              B += [A[i + 1]]
          else:
              flag = False
      A = B
      N = len(A)
      if flag:
          break
  
  if N == 1:
      print(1)
      exit()
  
  
  def is_possible(K):
      dp = [0] * 19
      for i in range(N - 1):
          if B[i] >= B[i + 1]:
              dp = dp[: B[i + 1]] + [0] * (19 - B[i + 1])
              flag = True
              for j in range(B[i + 1] - 1, -1, -1):
                  if dp[j] < K - 1:
                      dp[j] += 1
                      flag = False
                      break
                  else:
                      dp[j] = 0
              if flag:
                  return False
      return True
  
  
  def bis(x, y):
      if y == x + 1:
          return y
      elif is_possible((x + y) // 2):
          return bis(x, (x + y) // 2)
      else:
          return bis((x + y) // 2, y)
  
  
  print(bis(0, N))
  
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"}]