#include <bits/stdc++.h>

using namespace std;

int main()
{
    vector <int> a[26];
    vector <int> b[26];
    int n;
    cin >> n;
    string s;
    cin >> s;
    char arr[n];
    strcpy(arr, s.c_str());
    if(n < 26)
    {
        cout << "0";
    }
    else
    {
        //napravlljen prvi niz;
        for(int i = 0; i < n; i++)
        {
            int val = arr[i];
            if(i >= (val - 65))
            {
                a[val-65].push_back(i);
            }
        }
        //
        vector<int>::iterator it;
        for(int i = 25; i >= 0; i--)
        {
            if(i == 25)
            {
                for(int k = 0; k < a[i].size(); k++)
                {
                    b[i].push_back(1);
                }
            }
            else
            {
                int tt = 0;
                vector<int>::iterator i1 = a[i].begin();
                vector<int>::iterator i2 = a[i + i].end();
                i2 -= 1;
                vector<int>::iterator j1 = b[i].begin();
                vector<int>::iterator j2 = b[i + 1].end();
                j2 -= 1;
                while((*i1 < *i2) && (i2 >= a[i+1].begin()))
                {
                    tt += *j2;
                    j2--;
                    i2--;
                }
                b[i].push_back(tt);
            }
        }
        vector<int>::iterator ii;
        long long sum = 0;
        for(ii = b[0].begin(); ii < b[0].end(); ii++)
        {
            sum += *ii;
        }
        long long con = 10*10*10*10*10*10*10*10*10 + 7;
        double fin = sum % con;
        cout << fin << endl;
    }
    return 0;
}