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

int find_A(string s) {
	int i = 0;
	while (s[i] != 'A' && i < s.length()) i++;
	return i;
}

long long int abeceda(string s) {
	long long int k = 1, x = 1;
	for (int i = find_A(s) + 1; i < s.length(); i++) {
		provera:
		if (s[i] == s[i - 1]) x++;
		else {
			k *= x;
			k %= 1000000007;
			x = 1;
			if (s[i] != (s[i - 1] + 1)) {
				for (int j = i; j < s.length(); j++) {
					s[i] = s[i - 1];
				}
				s.resize(s.length() - 1);
				goto provera;
			}
		}
	}
	k *= x;
	k %= 1000000007;
	return k;
}

int main() {
	int n;
	cin >> n;
	string s;
	s.reserve(n);
	cin >> s;
	cout << abeceda(s);
	return 0;
}