#include <bits/stdc++.h>
using namespace std;
const int MX = 5009;
const long long mod = 1e9 + 7;
const long long inf = (1ll << 61);
int n, C[MX][MX], dp[MX][MX], last[500];
string s;
int main() {
  cin >> n >> s;
  s = "#" + s;
  for (int i = 0; i <= n; i++) {
    C[i][0] = 1;
    dp[0][i] = 1;
    for (int j = 1; j <= i; j++) {
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
    }
  }
  for (int len = 1; len <= n; len++) {
    memset(last, 0, sizeof(last));
    for (int p = 1; p <= n; p++) {
      dp[len][p] = dp[len - 1][p - 1];
      if (last[s[p]]) dp[len][p] -= dp[len - 1][last[s[p]]];
      dp[len][p] += mod;
      dp[len][p] %= mod;
      dp[len][p] += dp[len][p - 1];
      dp[len][p] %= mod;
      last[s[p]] = p;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (1ll * dp[i][n] * C[n - 1][i - 1]);
    ans %= mod;
  }
  cout << ans << endl;
}
