#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 5e3 + 10;
int dp[2][N], pre[N];
int cur[30];
void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
void init() { memset(cur, -1, sizeof(cur)); }
void solve(int n) {
  int *nex = dp[0], *cur = dp[1];
  for (int i = 0; i <= n; ++i) {
    cur[i] = 1;
  }
  for (int j = 1; j <= n; ++j) {
    memset(nex, 0, sizeof(dp[0]));
    for (int i = 1; i <= n; ++i) {
      add(nex[i], nex[i - 1]);
      add(nex[i], cur[i]);
      if (~pre[i]) add(nex[i], mod - cur[pre[i]]);
    }
    swap(cur, nex);
  }
  printf("%d\n", cur[n]);
}
char s[N];
int n;
int main() {
  while (~scanf("%d", &n)) {
    init();
    scanf("%s", s + 1);
    for (int i = 1; i <= n; ++i) {
      pre[i] = cur[s[i] - 'a'];
      cur[s[i] - 'a'] = i;
    }
    solve(n);
  }
  return 0;
}
