n = gets.to_i
input = []
n.times do
    input.push(gets.to_i)
end

result = [input[0]]
min = input[0]
1.upto(input.size - 1) do |index|
    val = input[index]
    if val <= min
        result.push(val)
        min = val
        next
    end
    result.each.with_index do |r, i|
        if r < val
            result[i] = val
            break
        end
    end
end
puts result.size