#include <bits/stdc++.h>
int add(int a, int b) { return (a + b) % ((long long)1e9 + 7); }
int sub(int a, int b) {
  return (a - b + ((long long)1e9 + 7)) % ((long long)1e9 + 7);
}
int main() {
  static char s[5000 + 1];
  static int choose[5000 + 1][5000 + 1], dp[5000][5000], aa[26], bb[5000];
  int n, l, i, j, cnt;
  scanf("%d", &n);
  scanf("%s", s);
  for (i = 0; i < 26; i++) aa[i] = -1;
  for (i = 0; i < n; i++) {
    int c = s[i] - 'a';
    if (aa[c] == -1) dp[0][i] = 1;
    bb[i] = aa[c];
    aa[c] = i;
  }
  for (l = 0; l < n - 1; l++) {
    int sum;
    memset(aa, 0, 26 * sizeof *aa);
    sum = 0;
    for (i = l; i < n; i++) {
      int c = s[i] - 'a';
      dp[l + 1][i] = sub(sum, aa[c]);
      sum = add(sum, dp[l][i]);
      aa[c] = add(aa[c], dp[l][i]);
    }
    for (i = n - 1; i > l; i--)
      if ((j = bb[i]) >= 0) dp[l + 1][i] = sub(dp[l + 1][i], dp[l + 1][j]);
  }
  for (i = 0; i <= n; i++) {
    choose[i][0] = 1;
    for (j = 1; j <= i; j++)
      choose[i][j] = add(choose[i - 1][j], choose[i - 1][j - 1]);
  }
  cnt = 0;
  for (l = 0; l < n; l++) {
    for (i = 1; i < n; i++) dp[l][i] = add(dp[l][i - 1], dp[l][i]);
    cnt = add(
        cnt, (long long)dp[l][n - 1] * choose[n - 1][l] % ((long long)1e9 + 7));
  }
  printf("%d\n", cnt);
  return 0;
}
