#include <bits/stdc++.h>
using namespace std;
int add(int x, int y) {
  return ((x + y) % 1000000007 + 1000000007) % 1000000007;
}
int mul(int x, int y) { return (long long)x * y % 1000000007; }
int mypow(int x, int c) {
  int ret = 1;
  while (c > 0) {
    if (c & 1) {
      ret = mul(ret, x);
    }
    c /= 2;
    x = mul(x, x);
  }
  return ret;
}
int dp[5005][26], dpSum[5005], last[5005][26];
int combi[5005][5005];
void init() {
  for (int i = 0; i < 5005; ++i) {
    combi[i][i] = combi[i][0] = 1;
    for (int j = 1; j < i; ++j) {
      combi[i][j] = add(combi[i - 1][j], combi[i - 1][j - 1]);
    }
  }
}
char s[5005];
void solve() {
  int n;
  scanf("%d ", &n);
  scanf(" %s ", s + 1);
  init();
  for (int i = 1; i <= n; ++i) {
    int len = i;
    int c = s[i] - 'a';
    if (s[i - 1] == s[i]) {
      continue;
    }
    for (int j = len - 1; j >= 0; --j) {
      if (j == 0) {
        if (dp[1][c] == 0) {
          ++dpSum[1];
          dp[1][c] = 1;
        }
      } else {
        int tmp = add(dpSum[j], -dp[j][c]);
        tmp = add(tmp, -last[j][c]);
        last[j][c] = add(dpSum[j], -dp[j][c]);
        dp[j + 1][c] = add(dp[j + 1][c], tmp);
        dpSum[j + 1] = add(dpSum[j + 1], tmp);
      }
    }
  }
  int ret = 0;
  for (int i = 1; i <= n; ++i) {
    ret = add(ret, mul(dpSum[i], combi[n - 1][i - 1]));
  }
  printf("%d\n", ret);
}
int main() {
  solve();
  return 0;
}
