#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


using namespace std;
const ll MOD =1e9 +7;
const int N=1000005;
int n;
string s;
ll dp[N][26];

int main()
{
  ios
  cin>>n;
  cin>>s;
  int sum=0;
  for (int i=0; i<n; i++)
  {
      if (s[i]=='A') sum++;

     if (i==0)
     {
         if (s[0]=='A') dp[i][0]=1;

         else dp[i][0]=0;


         for (int j=1; j<26; j++)
      {
         dp[i][j]=0;

      }
     }
     else
     {
         for (int j=0; j<26; j++)
         {
             if(j==0)
             {
                 dp[i][j]=sum;
             }
             else
             {
                 if (s[i]!='A'+j) dp[i][j]=dp[i-1][j];

                 else
                 {
                     if (dp[i-1][j]+dp[i-1][j-1]>=MOD) dp[i][j]=dp[i-1][j]+dp[i-1][j-1]-MOD;

                     else dp[i][j]=dp[i-1][j]+dp[i-1][j-1];
                 }
             }
         }
      }
     }
  cout<<dp[n-1][25];

}