#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    long long n,i,dp[28];
    char niz[1000000];
    cin>>n;
    for(i=0;i<27;i++)dp[i]=0;
    for(i=0;i<n;i++)
    {
                    cin>>niz[i];
                    if(niz[i]-'A'==0)dp[0]++;
                    else{
                   dp[niz[i]-'A']=(dp[niz[i]-'A']+dp[niz[i]-'A'-1])%1000000007;
                    
                    
                    
                    
                    
                    
                    //cout<< dp[niz[i]-'A']<<" "<<niz[i]-'A'<<" ";
                    
                    }
                    }
                    cout<<dp[25];
                    cin>>n;
}