#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define FOR(n) for(int i = 0; i < n; i++)
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pdd pair<double, double>
#define mii map<int,int>
#define C const int
using namespace std;
C mxn = 1e6, MOD = 1e9 + 7;

int malo(int n, char a[], mii m){
    if(n<26) {
        cout << "0\n";
        return 0;
    }
    FOR(26){
        if(m[i]==0) {
            cout << "0\n";
            return 0;
        }
    }

    if(n==26){
        FOR(n-1){
            if(a[i]-'A' > a[i+1]-'A') {
                cout << "0\n";
                return 0;
            }
        }
        cout << "1\n";
        return 0;
    }
    if(n==27){
        bool izbacen = false;
        FOR(26){
            if(a[i]-'A' > a[i+1]-'A'){
                if(izbacen){
                    cout << "0\n";
                    return 0;
                }
                izbacen = true;
                i++;
            }
            if(a[i]==a[i+1]){
                cout << "2\n";
                return 0;
            }

        }
        cout << "1\n";
            return 0;
    }
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    int n; cin >> n;
    string s; cin >> s;

    char a[mxn];
    mii m;
    FOR(n){
        a[i]=s[i];
        m[s[i]-'A']++;
    }

    if(n<=27) {malo(n,a,m);return 0;}

    vector<vector<int>> dp(26,vector<int>(n));

    FOR(26){
        for(int j = 0; j < n; j++) dp[i][j]=0;
    }

    FOR(n){
        if(i==0){
            if(a[0]=='A')
                dp[0][0]=1;
        }
        else
        {


                    for(int j = 0; j < 26; j++)
                    {
                        if(j!=a[i]-'A')
                        {
                            dp[j][i]=dp[j][i-1];
                            if(dp[j][i]>MOD) dp[j][i] = dp[j][i] % MOD;
                        }
                    }
                    if(a[i]!='A')
                    {
                        dp[a[i]-'A'][i]=dp[a[i]-'A'][i-1] + dp[a[i]-'A'-1][i-1];
                        if(dp[a[i]-'A'][i] > MOD) dp[a[i]-'A'][i] = dp[a[i]-'A'][i] % MOD;
                    }

                    else
                    {dp[0][i]=dp[0][i-1]+1;
                        if(dp[0][i] > MOD) dp[0][i] = dp[0][i] % MOD;
                    }

        }
    }

    cout << dp[25][n-1];



}