#include<bits/stdc++.h>

using namespace std;

static const int INF = 1e9 + 7;

void hawawa()
{
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    if (str == "A") {
      cnt++;
    } else {
      if (!cnt) {
        cout << "NO\n";
        return;
      }
      cnt--;
    }
  }
  if (cnt) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  hawawa();
}