N = gets.chomp.to_i
numbers = N.times.map { gets.chomp.to_i }

stack = [numbers[0]]
stack_index = 0

1.upto(N-1) do |i|
    target = numbers[i]
    stack_index.downto(0) do |cursor|
        if cursor == 0 && target <= stack[0]
            stack.push target
            stack_index = stack.size - 1
            break
        end
        if target > stack[cursor]
            stack[cursor] = target
            break
        end
    end
end

puts stack.size
