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: import os
  import sys
  
  if os.getenv("LOCAL"):
      sys.stdin = open("_in.txt", "r")
  
  sys.setrecursionlimit(10**9)
  INF = float("inf")
  IINF = 10**18
  MOD = 10**9 + 7
  # MOD = 998244353
  
  
  N = int(sys.stdin.buffer.readline())
  A = list(map(int, sys.stdin.buffer.readline().split()))
  
  # (長さ、文字種)
  stack = [(0, 0)]
  ans = 0
  for a in A:
      popped = False
      while a < stack[-1][0]:
          stack.pop()
          popped = True
      l, c = stack[-1]
      if a > l:
          stack.append((a, 2 if popped else 1))
      elif a == l:
          stack[-1] = l, c + 1
      else:
          assert False
      ans = max(ans, stack[-1][1])
  
  while stack:
      _, c = stack.pop()
      ans = max(ans, c)
  print(ans)
  
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"}]