n = gets.to_i
as = []
n.times{ as << gets.to_i }

colors = []
as.each do |a|
  i = colors.bsearch_index{|x| x < a }
  if i.nil?
    colors.unshift(a)
  else
    colors[i] = a
  end
end

p colors.size
