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



int main()
{
    int n;
    cin >> n;
    long long rez = 1, k = 0;
    char slovo = 'A';
    string a;
    cin >> a;
    for (int i = 0; i < n; i++)
    {
        if (a[i] == slovo)
            k++;
        else if (k != 0)
        {
            rez = rez * k % 1000000007;
            slovo += 1;
            a[i] == slovo ? k = 1 : k = 0;
        }
    }
    if (k != 0)
    {
        rez = rez * k % 1000000007;
        slovo += 1;
    }
    if (slovo == 'Z' + 1)
        cout << rez;
    else
        cout << '0';
}