#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 5, mod = 1e9 + 7;
int dp[2][maxn], pd[2][maxn], c[26];
int32_t main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  dp[0][0] = 1;
  fill(pd[0], pd[0] + maxn, 1);
  for (int i = 0; i < n; i++) {
    fill(c, c + 26, -1);
    for (int j = 0; j < n; j++) {
      dp[(i + 1) % 2][j + 1] = pd[i % 2][j + 1];
      pd[0][0] = dp[0][0] = 0;
      pd[(i + 1) % 2][j + 1] =
          ((pd[(i + 1) % 2][j] + dp[(i + 1) % 2][j + 1]) % mod -
           dp[(i + 1) % 2][c[s[j] - 'a'] + 1] + mod) %
          mod;
      c[s[j] - 'a'] = j;
    }
  }
  cout << pd[n % 2][n];
}
