15
txxtxttxxttxtxx
 3
myw
 127
xixtxixnxixtxixlxixtxixnxixtxixoxixtxixnxixtxixlxixtxixnxixtxixhxixtxixnxixtxixlxixtxixnxixtxixoxixtxixnxixtxixlxixtxixnxixtxix
 1
a
 10
isssisssss
 2
ff
 1
z

27824
 10
 944124121
 1
 176
 1
 1

#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 7;
const int maxn = (int)6e5 + 7;
const int lmaxn = (int)1e6 + 7;
const long long linf = (long long)1e16 + 7;
const long double eps = long double(1e-11);
const long long dx[] = {-1, 0, 0, 1};
const long long dy[] = {0, -1, 1, 0};
long long gcd(long long a, long long b) {
  while (b) a %= b, swap(a, b);
  return a | b;
}
long long lcm(long long a, long long b) { return (a * b / gcd(a, b)); }
int mul(int a, int b) { return (long long(a) * long long(b)) % inf; }
int n, ans;
int c[5001][5001], d[5001][5001], p[3][5001];
int l[5001], e[257];
string a;
void build(int i) {
  for (int j = 0; j <= n; ++j)
    p[i % 2][j] = ((!j ? 0 : p[i % 2][j - 1]) + d[i][j]) % inf;
}
int main() {
  cin >> n >> a;
  for (int i = 0; i < n; ++i) {
    l[i + 1] = (!e[a[i]] ? -1 : e[a[i]]);
    e[a[i]] = i + 1;
  }
  for (int i = 0; i <= n; ++i) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j < i; ++j)
      (c[i][j] += (c[i - 1][j] + c[i - 1][j - 1]) % inf) %= inf;
  }
  d[0][0] = 1;
  build(0);
  for (int len = 1; len <= n; ++len) {
    for (int i = 1; i <= n; ++i) {
      d[len][i] = (p[(len - 1) % 2][i - 1] - p[(len - 1) % 2][l[i]]);
      if (d[len][i] < 0) d[len][i] += inf;
      d[len][i] %= inf;
    }
    build(len);
  }
  for (int len = 1; len <= n; ++len) {
    int cc = 0;
    for (int j = 1; j <= n; ++j) (cc += d[len][j]) %= inf;
    (ans += mul(cc, c[n - 1][len - 1])) %= inf;
  }
  cout << ans % inf;
  return 0;
}
