#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7, INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long first) {
  return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;
}
const int N = 5e3 + 10;
int n, nn, a[N];
int f[N][27], g[N][27], C[N][N];
int main() {
  scanf("%d", &n), nn = n;
  for (int i = 1; i <= n; ++i) {
    char c;
    scanf(" %c", &c);
    if (c == a[i - 1] + 'a' - 1)
      --i, --n;
    else
      a[i] = c - 'a' + 1;
  }
  for (int i = 1; i <= n; ++i) {
    memcpy(g, f, sizeof f);
    for (int j = i - 1; j >= 1; --j) {
      for (int k = 1; k <= 26; ++k)
        if (k != a[i]) (f[j + 1][a[i]] += g[j][k]) %= P;
      (f[j + 1][a[i]] -= g[j + 1][a[i]]) %= P;
    }
    f[1][a[i]] = 1;
  }
  for (int i = 0; i <= nn; ++i) {
    C[i][0] = 1;
    for (int j = 1; j <= i; ++j) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % P;
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= 26; ++j)
      ans += (long long)C[nn - 1][i - 1] * f[i][j] % P;
  printf("%lld\n", (ans % P + P) % P);
}
