#include <vector>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cmath>

using namespace std;

void skrati(vector <char> slova,vector <char> *novi){
    int max;
    max = *min_element(slova.begin(),slova.end());

    for(int i = 0; i < slova.size(); i++){
        if(slova[i] == max){
            novi->push_back(slova[i]);
        } else if(slova[i] > max) {
            novi->push_back(slova[i]);
            max = slova[i];
        }
    }
}

int main(){
    int n,broj,m,exp = (pow(10,9)+7),v = 0;
    long long res,cnt = 1;
    vector <char> alfabet = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
    vector <char> slova;
    vector <char> novi;
    vector <char> ::iterator it;
    char c;

    scanf("%d",&n);

    for(int i = 0; i < n + 1; i++){
        scanf("%c",&c);
        slova.push_back(c);
    }

    skrati(slova,&novi);

    it = novi.begin();

    for(int i = 0; i < alfabet.size(); i++){
        m = count(it+v,novi.end(), alfabet[i]);
        if(m > 1){
            cnt = m * cnt;
        }
        v = m;
    }
    res = cnt % exp;

    printf("%lld",res);

    return 0;
}