#include <bits/stdc++.h>
using namespace std;
const int N = 5000 + 20;
long long int a[N], DP[N][N], dp[2][N], mark[30], jolo[30];
const long long int q = 1000 * 1000 * 1000 + 7;
vector<int> vec;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i <= n; i++) {
    DP[i][0] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      DP[i][j] = (DP[i - 1][j] + DP[i - 1][j - 1]) % q;
    }
  }
  for (int i = 0; i < n; i++) {
    while (!vec.empty() and vec.back() == (s[i] - 'a')) {
      vec.pop_back();
    }
    vec.push_back(s[i] - 'a');
  }
  int m = vec.size();
  int ans = 0;
  dp[1][0] = 1;
  mark[vec[0]] = 1;
  for (int j = 1; j < m; j++) {
    dp[1][j] = dp[1][j - 1];
    if (mark[vec[j]] == 0) {
      dp[1][j]++;
    }
    mark[vec[j]] = 1;
  }
  ans = dp[1][m - 1];
  for (int i = 2; i <= m; i++) {
    fill(mark, mark + 30, 0);
    fill(jolo, jolo + 30, 0);
    jolo[vec[0]] = dp[1][0];
    for (int j = 1; j < m; j++) {
      dp[0][j] = (dp[1][j - 1] + q - jolo[vec[j]]) % q;
      mark[vec[j]] = 1;
      jolo[vec[j]] = dp[1][j];
    }
    dp[1][0] = 0;
    for (int j = 1; j < m; j++) {
      dp[1][j] = (dp[1][j - 1] + dp[0][j]) % q;
    }
    ans += (dp[1][m - 1] * DP[n - 1][i - 1]) % q;
    ans %= q;
  }
  cout << ans << "\n";
}
