#include <iostream>
#include <stack>
#include <string>
using namespace std;

int main() {
  stack<string> s;
  int n;
  cin >> n;
  string a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];

  for (int i = 0; i < n; i++) {
    if (a[i] == "A") s.push("A");
    else {
      if (!s.empty() && s.top() == "A") s.pop();
      else s.push("Un");
    }
  }
  if (s.empty()) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}