#配列arrに値xを最適に挿入(もしくは置換)する。配列arrは重複あり・降順
def insert(arr,x)
  len = arr.length
  if x > arr[-1]
    d = (len-1) / 2
    i = d
    #2分探索ここから
    while len > 1
      if arr[i] < x
        i -= d
        len = len - d - ((len-1)%2)
        d = (len-1) / 2
        i += d
      else
        len = len - d - 1
        d = (len-1) / 2
        i += d + 1
      end
    end
    #2分探索ここまで
    arr[i] = x
  else
    arr.push(x)
  end
end

n = gets.to_i
a = []
n.times do |i|
  a[i] = gets.to_i
end
arr = [a[0]]
(n-1).times do |i|
  insert(arr,a[i+1])
end
puts arr.length