#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,k;
bool yes = true;
cin >> n;
k = 0;
ll g = 1;
char s[n];
for(int l=0;l<n;++l){
    cin >> s[l];
    if(s[l] == char(65) && yes){
        k = l;
        yes = false;
    }
}
int z[26];
for(int x=0;x<26;++x){
    z[x] = 0;
}
int i=65;
for(int j=k;j<n;++j){
    if(s[j] == char(i)){
        ++z[i-65];
    }
    if(s[j] != char(i)){
        ++i;
        while(s[j]!=char(i)){
        ++j;
    }
    ++z[i-65];
    }
}
for(int j=0;j<26;++j){
    g = (g*z[j])%1000000007;
}
ll q = (g==1)? 0:g;
cout << q;
return 0;
}