#include <bits/stdc++.h>
using namespace std;
int l;
char A[5003];
int DP[5003][2];
int AC[5003][2];
int M[256];
int cmb[5003];
int fastpow(int b, int e) {
  int ans = 1;
  while (e) {
    if ((e & 1)) ans = ((long long)ans * b) % 1000000007;
    e >>= 1;
    b = ((long long)b * b) % 1000000007;
  }
  return ans;
}
int main(int nargs, char **args) {
  cin >> l >> A;
  A[l++] = '$';
  cmb[0] = 1;
  for (int i = 1; i < l; i++) {
    cmb[i] = ((long long)cmb[i - 1] * (l - i - 1) % 1000000007) *
             fastpow(i, 1000000007 - 2) % 1000000007;
  }
  for (int i = 1; i <= l; i++) {
    DP[i][1] = (M[A[i - 1]] == 0);
    AC[i][1] = AC[i - 1][1] + DP[i][1];
    M[A[i - 1]] = i;
  }
  int ans = 0;
  for (int j = 2; j <= l; j++) {
    memset(M, 0, sizeof M);
    int ci = (j & 1);
    for (int i = 1; i <= l; i++) {
      char c = A[i - 1];
      DP[i][ci] = (AC[i - 1][!ci] - AC[M[c]][!ci] + 1000000007) % 1000000007;
      AC[i][ci] = (AC[i - 1][ci] + DP[i][ci]) % 1000000007;
      M[c] = i;
    }
    ans = (ans + (long long)DP[l][ci] * cmb[j - 2]) % 1000000007;
  }
  cout << ans << endl;
  return 0;
}
