#include <cstdio>

int main() {
  size_t n;
  scanf("%zu", &n);

  int a = 0;
  for (size_t i = 0; i < n; ++i) {
    char buf[4];
    scanf(" %s", buf);
    char c = buf[0];
    if (c == 'A') {
      ++a;
    } else {
      if (a == 0) return puts("NO"), 0;
      --a;
    }
  }
  puts(!a? "YES": "NO");
}

