#include <bits/stdc++.h>
using namespace std;
const int block_size = 320;
const long long mod = 1e9 + 7;
const long double eps = 1e-9;
const int inf = mod;
const double PI = atan(1) * 4;
template <typename T>
inline int sign(const T& a) {
  if (a < 0) return -1;
  if (a > 0) return 1;
  return 0;
}
template <typename T>
inline void in(T& x) {
  x = 0;
  T f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
template <typename A, typename B>
inline void in(A& x, B& y) {
  in(x);
  in(y);
}
template <typename A, typename B, typename C>
inline void in(A& x, B& y, C& z) {
  in(x);
  in(y);
  in(z);
}
template <typename A, typename B, typename C, typename D>
inline void in(A& x, B& y, C& z, D& xx) {
  in(x);
  in(y);
  in(z);
  in(xx);
}
template <class T>
void upd(T& a, T& b) {
  a = max(a, b);
}
inline void add(int& a, int b) {
  a += b;
  a %= mod;
}
int n;
char s[5010];
int last[5010][27];
long long tot[5010][5010];
int vis[27];
int main() {
  scanf("%d %s", &n, s + 1);
  for (int i = 1; i < n + 1; i++) s[i] = s[i] - 'a' + 1;
  for (int i = 0; i < 27; i++) last[0][i] = -1;
  for (int i = 1; i < n + 1; i++) {
    for (int j = 0; j < 27; j++) {
      if (j == s[i]) {
        last[i][j] = -1;
        continue;
      }
      if (s[i - 1] == j) {
        last[i][j] = i - 1;
      } else {
        last[i][j] = last[i - 1][j];
      }
    }
  }
  for (int i = 0; i < 5010; i++) tot[i][0] = 1;
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < n + 1; j++) {
      for (int k = 1; k < 27; k++) {
        if (last[j][k] == -1) continue;
        tot[i][j] += tot[i - 1][last[j][k]];
      }
      tot[i][j] += tot[i - 1][j] + 1;
      tot[i][j] %= mod;
    }
  }
  long long ans = 0;
  for (int i = n + 1; i >= 1; i--) {
    if (vis[s[i]]) continue;
    vis[s[i]] = 1;
    ans += tot[n][i] - tot[n - 1][i];
  }
  cout << (ans % mod + mod) % mod;
  return 0;
}
