#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define INF 1000000000
#define LINF 1000000000000000LL
#define pb push_back
#define all(x) x.begin(), x.end()
#define len(s) (int)s.size()
#define test_case { int t; cin>>t; while(t--)solve(); }
#define single_case solve();
#define line cerr<<"----------"<<endl;
#define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); }
#define mod 1000000007LL
int n;
string s;
ll a[30];

int main()
{
    ios
    cin>>n;
    cin>>s;
    for(int i = 0;i<n;i++)
    {
        if(s[i]=='A') a[0]++;
        else a[s[i]-'A'] += a[s[i]-'A'-1];
        if(a[s[i]-'A']>=mod) a[s[i]-'A'] %= mod;
    }

    cout<<a['Z'-'A'];



    return 0;
}