#include <iostream>
#include <string>

using namespace::std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	char a;
	int dobri[26]; // losi[26];
	for (int i = 0; i < 26; i++) {
		dobri[i] = 0;
		//losi[i] = 0;
	}
	char curr = 'A' - 1;
	string s = "";
	for (int i = 0; i < n; i++) {
		cin >> a;
		s += a;
		if (a > curr) {
			dobri[a - 'A']++;
			curr = a;
		}
		else if (a == curr) {
			dobri[a - 'A']++;
		}
	}
	long long proiz = 1;
	long long mod = 1000000007;
	for (auto i : dobri) {
		proiz = (proiz * i) % mod;
	}
	cout << proiz;
	return 0;
}