n = gets.to_i
aun = 0
flag = true
n.times{
    if gets.chomp == "A"
        aun += 1
    else
        aun -= 1
        if aun < 0
            flag = false
            break
        end
    end
}
puts (aun == 0 && flag) ? "YES" : "NO"
