#include <bits/stdc++.h>
using namespace std;
std::mt19937 rng(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) {
  return (b == 0LL ? a : gcd(b, a % b));
}
long long exp(long long b, long long e, long long m) {
  b %= m;
  long long ans = 1;
  for (; e; b = b * b % m, e /= 2)
    if (e & 1) ans = ans * b % m;
  return ans;
}
const int N = 5050;
const int M = 1e9 + 7;
char s[N];
int dp[2][N][27];
int C[N][N];
int last[N][30];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  for (int i = 0; i < (N); ++i) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < (i); ++j) {
      C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
      C[i][j] -= (C[i][j] >= M) * M;
    }
  }
  for (int i = 1; i < (n + 1); ++i) cin >> s[i], s[i] -= 'a';
  dp[0][0][26] = 1;
  int cur = 0;
  for (int i = 1; i < (n + 1); ++i) {
    cur ^= 1;
    int la = cur ^ 1;
    for (int t = 0; t < (i + 1); ++t)
      for (int j = 0; j < (27); ++j) {
        dp[cur][t][j] = dp[la][t][j];
      }
    for (int t = 0; t < (i); ++t) {
      int Cnt = 0;
      for (int j = 0; j < (27); ++j)
        if (j != s[i]) {
          Cnt += dp[la][t][j];
          Cnt -= (Cnt >= M) * M;
        }
      int& x = dp[cur][t + 1][s[i]];
      Cnt -= last[t][s[i]];
      Cnt += (Cnt < 0) * M;
      last[t][s[i]] += Cnt;
      last[t][s[i]] -= (last[t][s[i]] >= M) * M;
      x += Cnt;
      x -= (x >= M) * M;
    }
  }
  long long res = 0;
  for (int t = 1; t < (n + 1); ++t) {
    long long qtd = 0;
    for (int j = 0; j < (26); ++j) {
      qtd += dp[cur][t][j];
      if (qtd >= M) qtd -= M;
    }
    res = (res + 1ll * qtd * C[n - 1][t - 1]) % M;
  }
  cout << res << "\n";
}
