#include <bits/stdc++.h>
using namespace std;

int main() {
    int N; cin >> N;
    int cnt = 0;
    bool ok = true;
    for(int i=0; i<N; ++i) {
        string s; cin >> s;
        if(s == "A") ++cnt;
        else --cnt;
        if(cnt < 0) ok = false;
    }
    if(cnt != 0) ok = false;
    cout << (ok ? "YES\n" : "NO\n");
}
