def com(arr)
    s = arr.size
    return 0 if s <= 1

    x = arr.shift
    color = 0
    t = []
    f = []

    arr.each do |y|
        if x == y then
            color += 1
        elsif x < y
            t << y
        else
            f << y
        end
    end

    color += com(t)
    color += 1 if (f != nil)
    color += com(f)

    return color
end

n = gets.to_i
a = []
n.times do
    a << gets.to_i
end

puts com(a)