#include <bits/stdc++.h>
using namespace std;
int occurrence[5002], o[5002];
int mod = 1000000007, dp[5002][5002];
string a;
int n;
int main() {
  cin >> n >> a;
  for (int i = 0; i < 26; i++) o[i] = n;
  for (int i = a.size() - 1; i >= 0; i--) {
    occurrence[i] = o[a[i] - 'a'];
    o[a[i] - 'a'] = i;
  }
  for (int i = 0; i < n; i++) dp[i][n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = n - 1; j >= 0; j--) {
      dp[i][j] = (dp[i + 1][j] + dp[i][j + 1]) % mod;
      if (occurrence[i] < n) {
        dp[i][j] = (dp[i][j] + mod - dp[occurrence[i]][j + 1]) % mod;
      }
    }
  }
  cout << dp[0][0] << endl;
}
