#include <bits/stdc++.h>
using namespace std;
char A[5005];
int dp[5005][5005], sum[5005][5005], prv[5005];
long long int f[100007];
long long int MOD = 1000000007;
long long pow(long long int a, long long int b) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y);
      if (x > MOD) x %= MOD;
    }
    y = (y * y);
    if (y > MOD) y %= MOD;
    b /= 2;
  }
  return x;
}
long long InverseEuler(long long int n) { return pow(n, MOD - 2); }
long long C(long long int n, long long int r) {
  if (n == 0) return 1;
  if (r < 0) return 0;
  if (r == 0) return 1;
  return (f[n] * ((InverseEuler(f[r]) * InverseEuler(f[n - r])) % MOD)) % MOD;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  for (int x = 0; x < 100007; x++) {
    f[x] = 1;
  }
  for (int i = 2; i < 100007; i++) f[i] = (f[i - 1] * i) % MOD;
  long long int n;
  cin >> n;
  cin >> (A + 1);
  vector<int> X(26, 0);
  dp[0][0] = sum[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    dp[0][i] = dp[i][0] = 0;
    sum[0][i] = 1;
    sum[i][0] = 0;
  }
  for (int i = 1; i <= n; i++) {
    prv[i] = X[A[i] - 'a'];
    X[A[i] - 'a'] = i;
  }
  for (int i = 1; i <= n; i++) {
    for (int l = 1; l <= n; l++) {
      dp[l][i] = sum[l - 1][i - 1];
      if (prv[i] != 0) {
        long long int a = dp[l][i], b = sum[l - 1][prv[i] - 1],
                      c = dp[l - 1][prv[i]];
        a = (a - b - c + MOD) % MOD;
        dp[l][i] = a;
      }
      long long int z, x = sum[l][i - 1], y = dp[l][i];
      z = (x + y) % MOD;
      sum[l][i] = z;
    }
  }
  long long int sum_ = 0;
  for (int i = 1; i <= n; i++) {
    if (sum[i][n] != 0) sum_ = (sum_ + sum[i][n] * C(n - 1, i - 1)) % MOD;
  }
  cout << sum_ << endl;
  return 0;
}
