#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define en '\n'
#define ld long double
#define sz(a) a.size()
using namespace std;
//const int mod=998244353;
const int mod=1e9+7;
const int maxn=1e6+10;
const int inf=2e9;
const ll linf=4e18;
vector<int> adj[26];
ll dp[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
    int n;
    string s;
    cin>>n>>s;
    for(int i=0;i<n;i++)adj[s[i]-'A'].pb(i);
    for (auto u : adj[0])dp[u]=1;
    for (int i=0;i<n;i++){
        if(s[i]=='A')continue;
        for (auto u : adj[s[i]-1-'A']){
            if(u>i)break;
            dp[i]+=dp[u];
            dp[i]%=mod;
        }
    }
    int ans = 0;
    for (auto u : adj[25]){
        ans += dp[u];
        ans %= mod;
    }
    cout<<ans;
    return 0;
}