n = gets.to_i
numbers = []
n.times do
  numbers << gets.to_i
end
colors = []
numbers.each do |number|
  index = colors.index(colors.bsearch { |x| x < number })
  if index
    colors[index] = number
  else
    colors << number
  end
end
puts colors.length