#include <bits/stdc++.h>
using namespace std;
long long answer;
long long n;
string a;
long long A[26][5020], tot[5020];
int main() {
  scanf("%d", &n);
  cin >> a;
  a = "$" + a;
  for (int k = 0; k <= n; ++k) tot[k] = 1;
  for (int i = 1; i <= n; ++i) {
    int cur = a[i] - 'a';
    long long now = 0;
    for (int k = 1; k <= n; ++k) {
      long long x = (1000000007ll + tot[k - 1] - A[cur][k - 1]) % 1000000007ll;
      if (k == n) answer = (x + answer) % 1000000007ll;
      now = (now + x) % 1000000007ll;
      tot[k] = (now + tot[k]) % 1000000007ll;
      A[cur][k] = (A[cur][k] + now) % 1000000007ll;
    }
    for (int k = 0; k <= n; ++k) A[cur][k] = tot[k];
  }
  cout << answer << endl;
}
