#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,c=0,k=0;
  string a;
  cin>>n;
  while(n--){
    cin>>a;
    if(a=="A")c++;
    else c--;
    if(c<0)k++;
  }
  cout<<((k||c)?"NO":"YES")<<endl;
}