#include <iostream>
#include <string>

using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	int a, b;
	a = b = 0;
	bool h = true;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s == "A") {
			a++;
		} else {
			a--;
		}
		if (a < 0) {
			h = false;
		}
	}
	if (a > 0) {
		h = false;
	}
	if (h) {
		cout << "YES" << endl;
 	} else {
		cout << "NO" << endl;
	}
	return 0;
}