#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fi first
#define se second
#define ld long double
#define N_5 100010
#define N_6 1000010
#define N_7 10000010
#define N_8 100000010
#define N_9 1000000010
#define ost 1000000007
#define ldb long double
#define ull unsigned long long
using namespace std;

void solve() {
    int n ;
    cin >> n ;
    string s ;
    cin >>s ;

    static int dp[N_6][27];// na koliko substringova A--j postoji do i-tog indeksa

    for (int i = 0 ; i <= n ; i++ ) dp[i][0] = 1 ;
    for (int i = 1 ; i <= n ; i++ ) {
        int k = s[i-1]-'A'+1;
        for (int j=0 ; j <= 26 ; j++ ) {
            dp[i][j] = dp[i-1][j];
        }
        dp[i][k] += dp[i-1][k-1];
        dp[i][k] %= ost;
    }

    cout << dp[n][26];

} 
 
 
int main () {
    
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t =1;
    //cin >>t ;
    while(t--) 
        solve();
}