#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long n, m, a[10000], f[10000][30], ff[10000][30], sum[10000], su[10000],
    c[5005][5005], ans;
int main() {
  scanf("%lld", &n);
  m = n;
  for (int i = 1; i <= n; i++) {
    char ch = '1';
    while (ch < 'a' || ch > 'z') scanf("%c", &ch);
    if (ch == a[i - 1] + 97 && i > 1)
      --i, --n;
    else
      a[i] = ch - 97;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++)
      for (int k = 0; k < 26; k++) ff[j][k] = f[j][k];
    for (int j = 1; j <= n; j++) su[j] = sum[j];
    for (int j = 1; j < i; j++) {
      long long r = (su[j] - ff[j][a[i]] - ff[j + 1][a[i]]) % mod;
      f[j + 1][a[i]] += r;
      f[j + 1][a[i]] %= mod;
      sum[j + 1] += r;
      sum[j + 1] %= mod;
    }
    if (!f[1][a[i]]) f[1][a[i]] = 1, ++sum[1];
  }
  for (int i = 0; i <= m; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= i; j++)
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 26; j++)
      ans = (ans + c[m - 1][i - 1] * f[i][j] % mod) % mod;
  printf("%lld", ans);
}
