#include <bits/stdc++.h>
using namespace std;

#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define inf INT_MAX
#define llinf LLONG_MAX
#define mt make_tuple
#define parll pair<ll,ll>
#define parii pair<int,int>
#define mp make_pair
#define mod 1000000007

int main()
{
    ios;

    ll n,p=26,P[p]; string A;
    for ( int i = 0; i < p; i++ )
    {
        P[i] = 0;
    }

    cin >> n; cin >> A;

    ll k;
    for ( int i = 0; i < n; i++ )
    {
        k = A[i]>'A'?P[A[i]-'A'-1]:1;
        P[A[i]-'A'] = (P[A[i]-'A']+k)%mod;
    }

    cout << P[p-1]%mod;

    return 0;
}