#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define fb(i,b,a) for(int i=b;i>=a;i--)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1000005;
const int inf = 1e9 + 5;
const int mod = 1e9 + 7;

int n;
string s;

ll dp[maxn][30];

ll add(ll a, ll b){
    return (a + b) % mod;
}
ll mul(ll a, ll b){
    return (a * b) % mod;
}
ll power(ll a, ll b){
    if(!b)return 1;
    ll pola = power(a, b / 2);
    pola = mul(pola, pola);
    if(b % 2)pola = mul(pola, a);
    return pola;
}
ll inv(ll a){
    return power(a, mod - 2);
}

int main()
{
   ios::sync_with_stdio(false);
   cout.tie(nullptr);
   cin.tie(nullptr);
   cin >> n >> s;
   if(n < 26)return cout << 0, 0;
   s = ' ' + s;
   ff(i,1,n){
      int x = s[i] - 'A';
      if(x == 0)dp[i][x] = add(dp[i][x], 1ll);
      else if(dp[i - 1][x - 1] > 0ll)dp[i][x] = add(dp[i][x], dp[i - 1][x - 1]);
      ff(j,0,25)dp[i][j] = add(dp[i][j], dp[i - 1][j]);
   }
   cout << dp[n][25] << endl;
   return 0;

}
/**

12
AABBCCAABBCC


29
AABACDEFGHIJKLMNOPQRSTUVWXYZZ

**/