N = gets.to_i
a_list = N.times.map { gets.to_i }
list = []
a_list.each do |a|
  i = list.bsearch_index { |b| a <= b }
  if i
    if i == 0
      list.unshift(a)
    else
      list[i - 1] = a
    end
  else
    if list.empty?
      list.push(a)
    else
      list[-1] = a
    end
  end
end
puts list.size
