#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
const int sqrtN = 320;
int countA[sqrtN], countP[sqrtN];
map<int, int> dm[sqrtN];
void recomp(int ind) {
  int a, p;
  a = p = 0;
  for (auto& x : dm[ind]) {
    if (x.second != -1) {
      if (p != 0)
        p--;
      else
        (a++);
    } else {
      p++;
    }
  }
  countA[ind] = a;
  countP[ind] = p;
}
int getTop(int ind, int p) {
  for (auto& x : dm[ind]) {
    if (x.second != -1) {
      if (p != 0)
        p--;
      else
        return x.second;
    } else {
      p++;
    }
  }
}
int top() {
  int p = 0;
  for (int i = 0; i < sqrtN; ++i) {
    if (p - countA[i] < 0) return getTop(i, p);
    p += countP[i] - countA[i];
  }
  return -1;
}
const long long mod = 1e9 + 7;
long long sums(long long a, long long b) {
  long long ans = a + b;
  if (ans >= mod) ans -= mod;
  return ans;
}
long long mins(long long a, long long b) {
  long long ans = a - b;
  if (ans < 0) ans += mod;
  return ans;
}
int p = 31;
long long nextH(long long h, char a) { return h * p + (a - 'a') + 1; }
int last[26], sum[5010] = {0}, f[5010] = {0};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string str;
  cin >> str;
  f[0] = 1;
  for (int step = 0; step < n; ++step) {
    for (int i = 0; i < 26; ++i) last[i] = -1;
    sum[0] = 0;
    for (int i = 0; i < n; ++i) sum[i + 1] = sums(sum[i], f[i]);
    for (int i = 0; i < n; ++i) {
      f[i] = mins(sum[i + 1], sum[last[str[i] - 'a'] + 1]);
      last[str[i] - 'a'] = i;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) ans = sums(ans, f[i]);
  cout << ans;
  return 0;
}
