#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int main()
{
    int n;
    cin >> n;

    vector<vector<pair<int, int>>> slova;
    slova.resize(26);

    for (int i = 0; i < n; ++i)
    {
        char x;
        cin >> x;
        int slovo = static_cast<int>(x - 'A');
        slova[slovo].push_back(make_pair(i, 0));
    }

    if (!slova[0].empty())
    for (int i = 0; i < slova[0].size(); ++i)
        slova[0][i].second = 1;

    for (int i = 0; i < 25; ++i)
    {
        int j = 0;
        int k = 0;
        long long suma1 = 0;
        suma1 += slova[i][j].second % 1000000007;
        while (k < slova[i+1].size() && j < slova[i].size())
        {
            while (k < slova[i+1].size() &&
                   ((j+1 == slova[i].size()) || (j+1 < slova[i].size() && slova[i+1][k].first < slova[i][j+1].first && slova[i+1][k].first > slova[i][j].first)))
                {
                slova[i+1][k].second = suma1;
                k++;
                }
            j++;
            suma1 += slova[i][j].second % 1000000007;
        }
    }

    long long suma(0);
    for (int i = 0; i < slova[25].size(); ++i)
            suma += slova[25][i].second % 1000000007;

    bool provera(true);
    for (int i = 0; i < 26; ++i)
        if (slova[i].empty()) provera = false;

    if (provera) cout << suma;
    else cout << 0;

    return 0;
}