#include <algorithm>
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

const int MAX=1000;

#define hoge(i,n) for(int i=0;i<n;i++)

int main(){
    int N,s[MAX];
    string S[MAX];
    cin >> N;
    hoge(i, N){
        cin >> S[i];
        if(S[i]=="A"){s[i]=1;}else{s[i]=-1;}
    }
    int sum=0;
    hoge(i,N){
        sum+=s[i];
        if(sum<0){break;}
    }
    if(sum==0){cout<<"YES";}else{cout<<"NO";}

    cout<<endl;
    return 0;
}