#include <iostream>  
#include <cstdlib>
using namespace std;
int main() {
	char abc[] = {'A' ,'B' ,'C' ,'D' ,'E' ,'F' ,'G' ,'H' ,'I' ,'J' ,'K' ,'L' ,'M' ,'N' ,'O' ,'P' ,'Q' ,'R' ,'S' ,'T' ,'U' ,'V' ,'W' ,'X' ,'Y' ,'Z' };
	char k[1000000];
	int n, i, pr=0, br=0, count[26] = {};
	long long int res = 1;
	cin >> n;
	for (i = 0; i < n; i++)
		cin >> k[i];
	for (i = 0; i < n; i++) {
		pocetak:
		if (k[i] == abc[br]) {
			count[br]++;
			continue;
		}
		else if (k[i] == abc[br + 1]) {
			br++;
			goto pocetak;
		}
		else {
			pr = 1;
		}
	}
	for (i = 0; i < 26; i++) {
		res *= count[i];
		res %= 1000000007;
	}
	if (res == 1 && pr == 1)
		cout << 1;

	else if (res == 1 && pr == 0) 
		cout << 0;
	else
	cout << res;
	return 0;
}