#include <iostream>

using namespace std;

int main(){
    int N;
    cin>>N;
    int cnt = 0;
    while(N--){
        string s;
        cin>>s;
        // cout<<cnt<<endl;
        if(s[0]=='A')cnt++;
        else cnt--;
        if(cnt<0){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    if(cnt==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}