#include <bits/stdc++.h>
#define K int(2e5 + 5)
#define INF ll(1e17)
#define MOD (long long)(1e9 + 7)
#define endl "\n"
using namespace std;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

void solve(){
	int n; string s;
	cin >> n >> s;
	ll x[26] = {}, ans = 0;
	for (char i : s){
		int num = i - 'A';
		if (num == 0) ++x[0];
		else (x[num] += x[num - 1]) %= MOD;
	}
	cout << x[25] << endl;
}
 
int main(){
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
 
    return 0;
}