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>
static const int N = 5005;
static const long long MOD = 1000 * 1000 * 1000 + 7;
int head[127];
int f[N][N];
char s[N];
int n;
int mod_add(int x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
  return x;
}
int mod_sub(int x, int y) {
  x -= y;
  if (x < 0) x += MOD;
  return x;
}
int solve() {
  scanf("%d", &n);
  scanf("%s", s);
  f[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    char c = s[i - 1];
    int last = head[c];
    head[c] = i;
    f[i][0] = f[i - 1][0];
    for (int j = 1; j <= n; ++j) {
      f[i][j] = mod_add(f[i - 1][j], f[i][j - 1]);
      if (last) f[i][j] = mod_sub(f[i][j], f[last][j - 1]);
    }
  }
  printf("%d\n", f[n][n]);
  return 0;
}
int main(int argc, char* argv[]) {
  solve();
  return 0;
}
