#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main()
{
        int n; cin>>n;
        int c1=0,c2=0;
        rep(i,n){
                string s; cin>>s;
                if(s=="A") c1++;
                else c2++;
                if(c1<c2){
                        cout<<"NO"<<endl;
                        goto g;
                }
        }
        if(c1==c2) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
g:;
}