#include<bits/stdc++.h>
using namespace std;
 
signed main(){
int a;
cin>>a;
int b=0;
for(int c=0;c<a;c++){
    string d;
    cin>>d;
    if(d=="A")b++;
    else b--;
    if(b<0){cout<<"NO"<<endl;goto e;}
    }
    if(b!=0)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    e:;
}