#include <bits/stdc++.h>
using namespace std;
const int MN = 5e3 + 100, mod = 1e9 + 7;
int dp[MN][MN];
int ps[MN][MN];
int last[MN];
int last2[26];
int main() {
  int n;
  string s;
  cin >> n >> s;
  memset(last, -1, sizeof last);
  memset(last2, -1, sizeof last2);
  for (int i = 0; i < n; i++) {
    if (last2[s[i] - 'a'] != -1) {
      last[i] = last2[s[i] - 'a'];
    }
    last2[s[i] - 'a'] = i;
    dp[0][i] = 1;
    ps[0][i] = dp[0][i];
    if (i > 0) {
      ps[0][i] += ps[0][i - 1];
      ps[0][i] %= mod;
    }
    if (last[i] != -1) {
      ps[0][i] += (mod - dp[0][last[i]]);
      ps[0][i] %= mod;
    }
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < n; j++) {
      dp[i][j] = ps[i - 1][j];
      ps[i][j] = dp[i][j];
      if (j > 0) {
        ps[i][j] += ps[i][j - 1];
        ps[i][j] %= mod;
      }
      if (last[j] != -1) {
        ps[i][j] += (mod - dp[i][last[j]]);
        ps[i][j] %= mod;
      }
    }
  }
  cout << ps[n - 1][n - 1];
}
