#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,j=1,k=0,n;
  string s;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>s;
    if(s=="A") k++;
    else k--;
    if(k<0) j=0;
  }
  cout << ((j&(k==0))?"YES":"NO") <<endl;
  return 0;
}