#include <bits/stdc++.h>
namespace IO {
char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T>
inline void read(T &n) {
  n = 0;
  register int ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}
}  // namespace IO
int const mod = 1e9 + 7;
int const MAXN = 8e3 + 5;
int pos[26][MAXN], len[26];
int f[2][MAXN], sum[MAXN];
char s[MAXN];
inline void Add(int &x, const int &y) {
  x += y - mod;
  x += (x >> 31) & mod;
}
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", s + 1);
  for (register int i = 1; i <= n; ++i) pos[s[i] - 'a'][++len[s[i] - 'a']] = i;
  int nxt = 0, cur = 1;
  f[0][1] = 1;
  for (register int i = 1; i <= n; ++i) {
    std::swap(cur, nxt);
    memset(f[nxt], 0, sizeof(f[nxt]));
    for (register int j = 1; j <= n; ++j)
      sum[j] = sum[j - 1], Add(sum[j], f[cur][j]);
    for (register int k = 0; k < 26; ++k) {
      for (register int j = 1; j <= len[k]; ++j) {
        Add(f[nxt][pos[k][j]], sum[pos[k][j]]);
        Add(f[nxt][pos[k][j]], mod - sum[pos[k][j - 1]]);
      }
    }
  }
  int ans = 0;
  for (register int i = 1; i <= n; ++i) Add(ans, f[nxt][i]);
  printf("%d\n", ans);
  return 0;
}
