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

typedef long long ll;
typedef vector<ll>vl1;
typedef vector<vl1> vl2;

int main()
{ ll i, j, k, kn, m, n, p, t, r, x, y, z, a, b, c;
  ll val, pos, tmp, suma, maxa, mina, naso, num, iza, vred;
  string str;
  char ch1;
  ll moda = 1000000007;
  cin>>n;
  cin>>str;
  vl2 mata(27, vl1(1));
  for(i=1;i<=n;i++)
  { val=str[i-1]-'A'+1;
    mata[val][0]++;
    mata[val].push_back(i);
  }
  naso=0;
  for(i=1;i<=26;i++)
  { val=mata[i][0];
    if(val==0) { naso=1; break;}
  }
  if(naso==1) {cout<<0; return 0;}
  vl2 ima(27, vl1(1));
  for(i=1;i<=26;i++)
  { val=mata[i][0];
    ima[i].resize(val+2);
    ima[i][0]=val;
    ima[i][val+1]=0;
  }
  val=ima[26][0];
  for(i=1;i<=val;i++) ima[26][i]=(val-i+1);
  for(i=25;i>=1;i--)
  { val=mata[i][0];
    iza=mata[i+1][0];
    j=iza;
    for(k=val;k>=1;k--)
    { vred=mata[i][k];
      while(j>0 && mata[i+1][j]>vred) j--;
      ima[i][k]=(ima[i][k+1]+ima[i+1][j+1])%moda;
    }
  }
  cout<<ima[1][1];
  
  return 0;
}
/*
29
AABACDEFGHIJKLMNOPQRSTUVWXYZZ

78
AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ
*/