#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long int n;
    cin >> n;
    char title[n];
    bool lookup_letters[26] = {false};

    long long total = 1;
    int n_adjacent = 0;

    char current_char = ' ';
    char previous_char = ' ';

    for(int i=0; i < n; i++)
    {
        cin >> title[i];

        if (title[i] == current_char && current_char > previous_char)
        {
            n_adjacent++;
            if (i+1 == n)
            {
                total *= n_adjacent;
            }
        }
        else
        {
            if (i > 0)
            {
                total *= n_adjacent;
                previous_char = max(previous_char, title[i-1]);
            }

            current_char = title[i];
            if (previous_char > current_char && !lookup_letters[current_char % 26])
            {
                cout << 0;
                return 0;
            }
            lookup_letters[title[i] % 26] = true;
            n_adjacent = 1;
        }
    }

    if (n <= 26)
    {
        cout << 0;
        return 0;
    }

    for(int i = 0; i < 26; i++)
    {
        if(!lookup_letters[i])
        {
            cout << 0;
            return 0;
        }
    }

    cout << total % 1000000007;

    return 0;
}