#include <bits/stdc++.h>
#define ll long long

using namespace std;

int N;
string s;
char treba;
char trenutno;
int suma;
int x;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	cin >> s;
	treba = 'A';
	x = 1;
	suma = 1;
	for (int i = 0; i < N; i++)
    {
        if ((s[i] == trenutno) && (s[i] == treba - 1))
            suma++;
        else
        {
            x = (x * suma) % 1000000007;
            suma = 1;
        }
        if (s[i] == treba)
            treba++;
        trenutno = s[i];
    }
    cout << (x * suma) % 1000000007;
	return 0;
}