#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6+56;
const int mod = 1000000007;

int n;
string s;
ll sum[26];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    cin >> s;

    for(int i = 1; i <= n; i++){
        char z = s[i-1];

        if(z == 'A'){
            sum[0]++;
            sum[0] %= mod;
            if(sum[0] < 0) sum[0] += mod;
            continue;
        }

        ll sta = sum[z-'A'-1];
        sta %= mod;
        if(sta < 0) sta += mod;

        sum[z-'A'] += sta;
        sum[z-'A'] %= mod;
        if(sum[z-'A'] < 0) sum[z-'A'] += mod;
    }

    cout << sum[25] << endl;
}