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

arr.each do |i|
  overwrite_index = stacks.bsearch_index { |target| target < i }
  if overwrite_index.nil?
    stacks.push(i)
  else
    stacks.delete_at(overwrite_index)
    insert_index = stacks.bsearch_index { |target| target <= i }
    if insert_index.nil?
      stacks.push(i)
    else
      stacks.insert(insert_index, i)
    end
  end
end
puts stacks.count