#include <iostream>

using namespace std;

int main(){
  int n;
  string c;
  cin >> n;

  int cnt = 0;
  bool x = true;
  
  while(n--){
    cin >> c;
    if(c == "A"){
      cnt++;
    }else {
      cnt--;
      if(cnt < 0){
	x = false;
      }
    }
  }
  if(cnt != 0 || x == false){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
}