# https://atcoder.jp/contests/abc134/tasks/abc134_e

n = gets.to_i
b_ary = [gets.to_i]

(n-1).times do
  v = gets.to_i
  index = b_ary.bsearch_index { |x| x < v }
  if index
    b_ary[index] = v
  else
    b_ary << v
  end
end
puts b_ary.size
