#include <iostream>

using namespace std;

string s;

void unos(int n){
    for (int i = 0; i < n; i++)
        cin >> s[i];
}

int f(char c, int n){
    int N = 0, M = 0;
    if (s[0] == c) N++;
    for (int i = 1; i < n; i++){
        if (s[i] == c){
            N++;
        }
        if ((s[i - 1] > s[i]) && (s[i] == c))
            M++;
    }
    return N - M;
}

int main()
{
    long long b, u = 1, br;
    b = 1000000007;
    int n;
    cin >> n;
    unos(n);
    for (char c = 'A'; c <= 'Z'; c++){
        br = f(c, n);
        u = u * br;
    }
    cout << u % b;
	return 0;
}