N = gets.to_i
As = readlines.map(&:to_i)
INF = 10**9

as = As.map{|a| -a}
lis = [as[0]]
as[1 .. -1].each do |a|
  if a > lis[-1]
    lis << a
  else
    lis[lis.bsearch_index{|x| a <= x}] = a
  end
end
puts lis.size == 1 ? N : lis.size