#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int B[5005][30], boo[30];
int dp[5005][5005];
int n;
char C[5005];
int main() {
  scanf("%d%s", &n, C);
  for (int i = (1); i <= (n); i++)
    for (int j = (0); j <= ((int)(26) - 1); j++) B[i][j] = -1;
  for (int i = (1); i <= (n); i++) {
    for (int j = i - 1; j > 0; j--) {
      int lol = (int)C[j - 1] - (int)'a';
      if (C[j - 1] != C[i - 1] && B[i][lol] == -1) B[i][lol] = j;
    }
  }
  for (int i = (1); i <= (n); i++) {
    for (int j = (1); j <= (n); j++) {
      dp[i][j] = 1;
      if (i == 1) continue;
      dp[i][j] += dp[i - 1][j];
      if (dp[i][j] >= mod) dp[i][j] -= mod;
      if (j == 1) {
        continue;
      }
      if (C[j - 1] == C[j - 2])
        dp[i][j] = dp[i][j - 1];
      else {
        dp[i][j]--;
        dp[i][j] += dp[i][j - 1];
        if (dp[i][j] >= mod) dp[i][j] -= mod;
        if (B[j - 1][(int)C[j - 1] - (int)'a'] != -1) {
          dp[i][j] -= dp[i - 1][B[j - 1][(int)C[j - 1] - (int)'a']];
          if (dp[i][j] < 0) dp[i][j] += mod;
        }
      }
    }
  }
  int res = 0;
  for (int i = n; i > 0; i--) {
    if (boo[(int)C[i - 1] - (int)'a']) continue;
    boo[(int)C[i - 1] - (int)'a'] = 1;
    res += dp[n][i];
    if (res >= mod) res -= mod;
    res -= dp[n - 1][i];
    if (res < 0) res += mod;
  }
  printf("%d\n", res);
  return 0;
}
