output_description: Print the minimum number of colors required to satisfy the condition.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1
      :
      A_N
attempt: import sys
  from operator import itemgetter
  
  fin = sys.stdin.readline
  N = [int(elem) for elem in fin().split()][0]
  a_list = [[int(elem) for elem in fin().split()][0] for _ in range(N)]
  
  
  list_count = 0
  num_list = [[list_count, a_list[0]]]
  prev_a = a_list[0]
  for each_a in a_list[1:]:
      if prev_a >= each_a:
          num_list[-1].append(prev_a)
          list_count += 1
          num_list.append([list_count, each_a])
      prev_a = each_a
  num_list[-1].append(a_list[-1])
  
  
  # print(sorted(num_list, key=itemgetter(2)))
  num_list = sorted(num_list, key=itemgetter(2))
  count = 1
  prev_start = num_list[0][1]
  prev_last = num_list[0][2]
  for each_list in num_list[1:]:
      current_start = each_list[1]
      current_last = each_list[2]
      if prev_last >= current_start:
          count += 1
      prev_start = current_start
      prev_last = current_last
  
  print(count)
  
problem_description: Statement
  
  You are given a sequence with N integers: A = \\{ A_1, A_2, \cdots, A_N \\}.
  For each of these N integers, we will choose a color and paint the integer
  with that color. Here the following condition must be satisfied:
  
    * If A_i and A_j (i < j) are painted with the same color, A_i < A_j.
  
  Find the minimum number of colors required to satisfy the condition.
samples: [{"input": "5\n    2\n    1\n    4\n    5\n    3", "output": "2\n    \n\nWe can satisfy the condition with two colors by, for example, painting 2 and 3\nred and painting 1, 4, and 5 blue.\n\n* * *"}, {"input": "4\n    0\n    0\n    0\n    0", "output": "4\n    \n\nWe have to paint all the integers with distinct colors."}]