#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
template <class T, class U>
inline void Max(T &a, U b) {
  if (a < b) a = b;
}
template <class T, class U>
inline void Min(T &a, U b) {
  if (a > b) a = b;
}
inline void add(int &a, int b) {
  a += b;
  while (a >= 1000000007) a -= 1000000007;
}
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = ans * (long long)a % 1000000007;
    a = (long long)a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
char s[5010];
int dp[5010][5010], ne[5010][26], f[5010], inv[5010], sum[5010];
int C(int a, int b) {
  return 1LL * f[a] * inv[a - b] % 1000000007 * inv[b] % 1000000007;
}
int main() {
  int T, i, j, k, ca = 0, m, K = 0, n;
  scanf("%d%s", &n, s);
  f[0] = 1;
  for (int i = 1; i < n + 1; i++) f[i] = f[i - 1] * (long long)i % 1000000007;
  inv[n] = pow(f[n], 1000000007 - 2);
  for (int i = n - 1; i >= 0; i--)
    inv[i] = inv[i + 1] * (long long)(i + 1) % 1000000007;
  int last[26] = {0};
  memset(last, -1, sizeof(last));
  sum[0] = 1;
  for (int i = 1; i < n + 1; i++) {
    int c = s[i - 1] - 'a';
    for (int j = i + 1 - 1; j >= 1; j--) {
      if (last[c] != -1) {
        dp[i][j] = (sum[j - 1] - dp[last[c]][j - 1] + 1000000007) % 1000000007;
        sum[j] = (0LL + sum[j] + dp[i][j] - dp[last[c]][j] + 1000000007) %
                 1000000007;
      } else {
        dp[i][j] = sum[j - 1];
        add(sum[j], dp[i][j]);
      }
    }
    last[c] = i;
  }
  int ans = 0;
  for (int i = 1; i < n + 1; i++)
    if (sum[i]) {
      add(ans, 1LL * sum[i] * C(n - 1, i - 1) % 1000000007);
    }
  printf("%d\n", ans);
  return 0;
}
