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

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