#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define pb push_back
#define x first
#define y second
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

const ll mod = 1e9 + 7;

int main()
{
    IOS;
    ll n;
    string s;
    cin >> n >> s;
    vector<ll> a(27, 0);
    a[0] = 1;
    for (ll i = 0; i < n; i++) {
        ll cur = ll(s[i]) - ll('A') + 1;
        a[cur] = (a[cur] + a[cur - 1]) % mod;
    }
    cout << a[26];
    return 0;
}