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

using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;

ll dp[28];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    dp[0] = 1;
    ll n;
    cin >> n;
    char c;
    int k;
    for(int i = 0; i < n; i++)
    {
        cin >> c;
        k  = c - 'A' + 1;
        dp[k] += dp[k - 1] % mod;
        dp[k] %= mod;
    }
    cout << dp[26];
}