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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int cnt=0;
    for (int i=0;i<N;++i){
        string S; cin >> S;
        cnt+=(S=="A"?1:-1);
        if (cnt<0){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << (cnt?"NO":"YES") << endl;
}
