#include <iostream>
#include <string>
using namespace std;

int n;
string s;

int main() {
	int stock = 0;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s == "A") stock++;
		else stock--;
		if (stock < 0) { cout << "NO" << endl; return 0; }
	}
	if (stock == 0) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
	return 0;
}