#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 7, M = 30 + 7;
const long long MOD = 1e9 + 7;
int n, m, k, t;
int ans[N], _dp[M][N];
int main() {
  scanf("%d\n", &n);
  char ch[n];
  scanf("%s", &ch);
  memset(ans, 0, sizeof ans), memset(_dp, 0, sizeof _dp);
  for (int i = 1; i <= n; i++) {
    int p = 1, idx = ch[i - 1] - 'a';
    for (int j = 1; j <= n; j++) {
      ans[j] = (ans[j] - _dp[idx][j] + MOD) % MOD;
      _dp[idx][j] = p, p = (p + ans[j]) % MOD;
      ans[j] = (ans[j] + _dp[idx][j]) % MOD;
    }
  }
  printf("%d", ans[n]);
  return 0;
}
