#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int MAX_N = 5000, SIGMA_SIZE = 26;
int pos[MAX_N][SIGMA_SIZE], f[MAX_N][MAX_N];
char s[MAX_N + 1];
int main() {
  int n;
  scanf("%d %s", &n, s);
  for (int i = 0; i < n; ++i) s[i] -= 'a';
  fill_n(pos[n - 1], SIGMA_SIZE, -1);
  pos[n - 1][s[n - 1]] = n - 1;
  for (int i = n - 2; i >= 0; --i) {
    copy(pos[i + 1], pos[i + 1] + SIGMA_SIZE, pos[i]);
    pos[i][s[i]] = i;
  }
  fill_n(f[n - 1], n, 1);
  for (int i = n - 2; i >= 0; --i) {
    f[i][n - 1] = f[i + 1][n - 1];
    for (int j = n - 2; j >= 0; --j)
      f[i][j] = ((long long)f[i][j + 1] -
                 (pos[j + 1][s[j]] >= 0 ? f[i + 1][pos[j + 1][s[j]]] : 0) +
                 f[i + 1][j] + MOD) %
                MOD;
  }
  int ans = 0;
  for (int j = 0; j < SIGMA_SIZE; ++j) ans = (ans + f[0][pos[0][j]]) % MOD;
  printf("%d\n", ans);
  return 0;
}
