#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int inf = 2e9;
const double pi = acos(-1.0);
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long sum[5050], f[5050], ans;
int n, last[30], vis[30];
char s[5050];
int main() {
  n = read();
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++)
    if (!vis[s[i] - 'a']) vis[s[i] - 'a'] = 1, f[i] = 1;
  for (int i = 2; i <= n; i++) {
    for (int i = 0; i <= 25; i++) last[i] = 0;
    sum[0] = 0;
    for (int j = 1; j <= n; j++) sum[j] = (sum[j - 1] + f[j]) % 1000000007;
    for (int j = 1; j <= n; j++) {
      f[j] = (sum[j] - sum[last[s[j] - 'a']] + 1000000007) % 1000000007;
      last[s[j] - 'a'] = j;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans = (ans + f[i]) % 1000000007;
  printf("%lld\n", ans);
  return 0;
}
