#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000 * 1000 * 1000 + 7;
const int MAXN = 5003;
int dp[MAXN][MAXN];
int sum[MAXN][MAXN];
void solve() {
  int m;
  cin >> m;
  string s;
  cin >> s;
  string str = s;
  s = "";
  int l = 0;
  while (l < m) {
    int r = l;
    while (r < m && str[l] == str[r]) r++;
    s += str[l];
    l = r;
  }
  int n = (int)s.size();
  vector<vector<int> > g(n);
  for (int i = 0; i < (int)(n); i++) {
    vector<int> used(128);
    used[s[i]] = true;
    for (int j = i; j < n; j++) {
      if (!used[s[j]]) {
        used[s[j]] = true;
        g[j].push_back(i);
      }
    }
  }
  vector<int> last(128, -1);
  for (int i = 0; i < (int)(n); i++) {
    sort(g[i].begin(), g[i].end());
    for (int j = 1; j <= m; j++) {
      if (last[s[i]] == -1) {
        dp[i][j] = 1;
      }
      long long tmp = 0;
      for (int pos : g[i]) {
        tmp += sum[j - 1][pos];
      }
      dp[i][j] = (tmp + dp[i][j]) % MOD;
      sum[j][i] = sum[j - 1][i] + dp[i][j];
      if (sum[j][i] >= MOD) {
        sum[j][i] -= MOD;
      }
    }
    last[s[i]] = i;
  }
  int ans = 0;
  for (int i = 0; i < (int)(n); i++) {
    ans += dp[i][m];
    if (ans >= MOD) ans -= MOD;
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
