N=gets.to_i
as =[]
for i in 0...N
  as << gets.to_i
end
as.reverse!
color_min=[as[0]]
for i in 1...N
  s=color_min.size
  judge = (0..s-1).bsearch{|j|as[i] < color_min[j]}

  if judge
    color_min[judge]=as[i]
  else
    color_min << as[i]
  end
end
puts color_min.size
