#include<iostream>
#include<string>
using namespace std;
int main(){
  string a;
  int n,c=0,c2=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    if(a=="A")c++;
    else{
      if(c!=0){
	c--;
	c2++;
      }
    }
  }
  if(c2*2==n)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}