N = gets.chomp.to_i
A = []
N.times do |i|
  A << gets.chomp.to_i
end

num_color = 1
maxs = { 1 => -1 }
max_value = 0
max_key = 1
A.each_with_index do |a, i|
  k, _ = maxs.select {|k,v| v < a}.sort_by {|k,v| -v }.first
  if k.nil?
    num_color += 1
    maxs[num_color] = a
  else
    maxs[k] = a
  end
end
puts maxs.keys.size
