#include <bits/stdc++.h>

using namespace std;

#define int ll
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;

const int mod = 1e9 + 7;

void f(int& x){
    if (x < 0){
        x %= mod;
        x += mod;
    }

    if (x >= mod)
        x %= mod;
}

int g(int x){
    f(x);
    return x;
}

signed main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr); 
    cerr.tie(nullptr);    

    int n;
    cin >> n;

    string s;
    cin >> s;

    vi dp(26, 0);
    for (int i = 0; i < n; ++i){
        int x = s[i] - 'A';
        if (!x){
            dp[0]++;
            continue;
        }
        dp[x] += dp[x-1];
        f(dp[x]);
    }

    cout << dp[25] << '\n';
}