#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
char str[5005];
int n, i, j, act;
int sol[5005];
int dp[5005][26];
int main() {
  scanf("%d\n%s", &n, str + 1);
  for (i = 1; i <= n; i++) {
    int curr = str[i] - 'a';
    act = 1;
    for (j = 1; j <= n; j++) {
      sol[j] = (sol[j] - dp[j][curr] + MOD) % MOD;
      dp[j][curr] = act;
      act = (act + sol[j]) % MOD;
      sol[j] = (sol[j] + dp[j][curr]) % MOD;
    }
  }
  printf("%d", sol[n]);
  return 0;
}
