#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int n;
  scanf("%d\n", &n);
  char c[5200];
  scanf("%s", c);
  string s(c);
  int pt = 0;
  int cnt = 0;
  std::vector<int> t;
  for (int i = 0; i < n; i++)
    if (i == 0 || s[i] != s[i - 1]) {
      cnt++;
      t.push_back(int(s[i] - 'a'));
    }
  std::vector<std::vector<int> > d(26, std::vector<int>(n + 1, 0));
  std::vector<std::vector<int> > last(26, std::vector<int>(n + 1, 0));
  for (int i = 0; i < n + 1; i++) last[t[0]][i] = mod - 1;
  for (int i = 0; i < n + 1; i++) {
    d[t[0]][i] = 1;
  }
  for (int sym = 1; sym < cnt; sym++) {
    int cur = t[sym];
    std::vector<int> cum(26, 0);
    for (int i = 1; i < n + 1; i++) {
      long long cand = 1;
      for (int j = 0; j < 26; j++) {
        if (j != cur) {
          cand += cum[j];
          cum[j] += d[j][i];
          if (cum[j] >= mod) cum[j] -= mod;
        }
      }
      cand %= mod;
      d[cur][i] += cand + last[cur][i];
      if (d[cur][i] >= mod) d[cur][i] -= mod;
      last[cur][i] = mod - d[cur][i];
      cum[cur] += d[cur][i];
      cum[cur] %= mod;
    }
  }
  long long ans = 0;
  for (int i = 0; i < 26; i++) ans += d[i][n];
  cout << ans % mod;
}
