#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9 + 7;
int dp[1000005][30]; //0 - nista, 1 - A, 2 - B
int n;

void base(){
    for(int i = 0; i < n; ++i)
        dp[i][0] = 1;
}

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

    base();

    for(int i = 1; i <= n; ++i){
        int cc = str[i - 1] - 'A' + 1;
        for(int j = 1; j <= 26; ++j){
            dp[i][j] = dp[i - 1][j];
            if(j == cc)
                dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % MOD;
        }
    }

    cout << dp[n][26] << "\n";
    return 0;
}
//koliko ima razlicitih ABC...Z nizova?