#include <iostream>

using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;

    long long int res, ob = 0;
    int neob[26];

    char tr = 'A';
    int j = 0;

    for(int i = 0; i < n; i++){
        neob[j] = 1;
        if(s[i] == tr)
            tr++;
        else{
            if(tr != 'A'){
                if(s[i] == tr-1){
                    neob[j]++;
                    j++;
                }
                else if(s[i] == 'A'){
                    ob++;
                }
            }
        }

    }

    int pomoc = 1;
    if(tr != 'Z'+1)
        cout << 0;
    else{
    for(int i = 0; i < j; i++){
        pomoc *= (neob[i]%1000000007)%1000000007;
    }
    if(ob > 0)
        res = (ob%1000000007 * pomoc%1000000007)%1000000007;
    else res = pomoc;
    cout << res;
    }
    return 0;
}