#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
//#include<algorithm>
//#include<cmath>
#include<string>
using namespace std;
int main() {
	int a=0,n;
	char in[3];
	cin >> n;
	while (n--) {
		cin >> in;
		if (in[0] == 'A') a++;
		else {
			a--;
			if (a < 0) {
				cout << "NO" << endl;
				return 0;
			}
		}
	}
	if (a) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}