#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,i;
    cin>>n;
    stack<string> stk;
    string s;
    for(i=0;i<n;i++){
        cin>>s;
        if(s=="A"){
            stk.push(s);
        }else if(s=="Un"&&!stk.empty()){
            stk.pop();
        }else{
            cout<<"NO\n";
            return 0;
        }
    }
    cout<<((stk.empty())?"YES\n":"NO\n");
    return 0;
}
