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
  import bisect
  
  # from collections import Counter, deque, defaultdict
  # from copy import deepcopy
  # from functools import reduce, lru_cache
  # from heapq import heappush, heappop
  # import itertools
  # import math
  # import string
  import sys
  
  
  ### stdin
  def input():
      return sys.stdin.readline().rstrip()
  
  
  def iIn():
      return int(input())
  
  
  def iInM():
      return map(int, input().split())
  
  
  def iInM1():
      return map(int1, input().split())
  
  
  def iInLH():
      return list(map(int, input().split()))
  
  
  def iInLH1():
      return list(map(int1, input().split()))
  
  
  def iInLV(n):
      return [iIn() for _ in range(n)]
  
  
  def iInLV1(n):
      return [iIn() - 1 for _ in range(n)]
  
  
  def iInLD(n):
      return [iInLH() for _ in range(n)]
  
  
  def iInLD1(n):
      return [iInLH1() for _ in range(n)]
  
  
  def sInLH():
      return list(input().split())
  
  
  def sInLV(n):
      return [input().rstrip("\n") for _ in range(n)]
  
  
  def sInLD(n):
      return [sInLH() for _ in range(n)]
  
  
  ### stdout
  def OutH(lst, deli=" "):
      print(deli.join(map(str, lst)))
  
  
  def OutV(lst):
      print("\n".join(map(str, lst)))
  
  
  ### setting
  sys.setrecursionlimit(10**6)
  ### utils
  int1 = lambda x: int(x) - 1
  ### constants
  INF = int(1e9)
  MOD = 1000000007
  dx = (-1, 0, 1, 0)
  dy = (0, -1, 0, 1)
  ###---------------------------------------------------
  
  N = iIn()
  A = iInLV(N)
  
  lst = [A[0]]
  for i in range(1, N):
      idx = bisect.bisect_left(lst, A[i])
      if idx == 0:
          lst.insert(0, A[i])
      else:
          lst[idx - 1] = A[i]
  
  print(len(lst))
  
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."}]