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

const long long MOD=1000000007;

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,g;
    string s;
    cin >> n;
    cin >> s;
    vector<long long> v(26,0);
    for (int i=0;i<n;i++)
    {
        g=s[i]-'A';
        if(s[i]=='A')
            v[0]++;
        else
            v[g]+=v[g-1];
        v[g]=v[g]%MOD;
    }
    cout << v[25];
}