#include <bits/stdc++.h>
#pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getrnd(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rng); }
template <typename T1, typename T2>
inline bool relax(T1& a, const T2& b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool strain(T1& a, const T2& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
const int MOD = 1e9 + 7;
int add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  if (a < 0) a += MOD;
  return a;
}
int mul(int a, int b) { return 1LL * a * b % MOD; }
int binpow(int a, ll n) {
  if (n < 0) a = binpow(a, MOD - 2), n *= -1;
  int res = 1;
  while (n) {
    if (n & 1) res = mul(res, a);
    a = mul(a, a);
    n /= 2;
  }
  return res;
}
int inv(int x) { return binpow(x, MOD - 2); }
const int N = 5005;
int lst[N][26], dp[N][N], C[N][N];
void solve() {
  int n;
  string s;
  cin >> n >> s;
  int m = n;
  string temp;
  for (int i = 0; i < n; ++i) {
    if (temp.empty() || temp.back() != s[i]) temp += s[i];
  }
  s.swap(temp);
  n = s.size();
  for (char& c : s) c -= 'a';
  for (int i = 0; i < N; ++i) {
    C[i][0] = 1;
    for (int j = 1; j <= i; ++j) C[i][j] = add(C[i - 1][j], C[i - 1][j - 1]);
  }
  for (int i = 0; i < 26; ++i) lst[0][i] = -1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 26; ++j) lst[i][j] = lst[i - 1][j];
    lst[i][s[i - 1]] = i - 1;
  }
  dp[0][1] = 1;
  for (int i = 1; i < n; ++i) {
    dp[i][1] = 1;
    for (int len = 2; len <= i + 1; ++len) {
      for (int j = 0; j < 26; ++j) {
        if (j == s[i] || lst[i][j] == -1) continue;
        dp[i][len] = add(dp[i][len], dp[lst[i][j]][len - 1]);
      }
    }
  }
  int ans = 0;
  for (int len = 1; len <= n; ++len) {
    for (int c = 0; c < 26; ++c) {
      if (lst[n][c] != -1)
        ans = add(ans, mul(dp[lst[n][c]][len], C[m - 1][len - 1]));
    }
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  srand(time(0));
  int t = 1;
  while (t--) solve();
  return 0;
}
