#include <iostream>
#include <string>
#include <bits/stdc++.h>
#include <cmath>

using namespace std;

int main()
{
    char a[26]={'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'};
    string s;
    int p=1,n;
    cin>>n>>s;
    for (int i=0;i<26;i++){
        int k;
        int j;
        if (i!=25){
            j=s.find_first_of(a[i]);
            k=s.find_first_of(a[i+1]);
            p*=count(s.begin()+j,s.begin()+k,a[i]);
        }else{
            j=s.find_last_of(a[i-1]);
            p*=count(s.begin()+j,s.end(),a[i]);
        }
        p%=int(pow(10,9))+7;
    }
    cout<<p;
}