N = gets.to_i
arr = N.times.map{ gets.to_i }
stacks = [arr.shift]

arr.each do |i|
  index = stacks.bsearch_index { |target| target < i }
  if index.nil?
    stacks.push(i)
  else
    stacks[index] = i
    stacks.sort.reverse
  end
end
puts stacks.count