#include <bits/stdc++.h>
using namespace std;
unsigned long long slova[26];
void check(int a)
{
    if(slova[a] > 1000000007)
            slova[a] = slova[a] % 1000000007;

return;
}
int main()
{
int y;
char t;
long long n;
cin >> n;
for(int i = 0; i < n; i++)
{
    scanf(" %c", &t);
    y = t - 65;
    if(y == 0)
        slova[0]++;
    else
        slova[y] += slova[y-1];

check(y);
}

cout << slova[25];
    return 0;
}