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

using namespace std;

int N;
string s;
char treba;
char trenutno;
int suma;
ll x;
bool jeste;

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] == treba)
        {
            treba++;
            x = (x * suma) % 1000000007;
            suma = 1;
        }
        else if ((s[i] == trenutno) && (s[i] == treba - 1))
        {
            suma++;
            jeste = true;
        }
        else
        {
            x = (x * suma) & 1000000007;
            suma = 1;
            jeste = true;
        }
        trenutno = s[i];
    }
    if (jeste)
        cout << (x * suma) % 1000000007;
    else
        cout << 0;
	return 0;
}