#include <bits/stdc++.h>
using namespace std;
int n, lst[350], acum[5005][5005], dp[5005][5005];
string s;
int main() {
  scanf("%d", &n);
  cin >> s;
  string aux = "";
  aux += s[0];
  for (int i = 1; i < n; i++)
    if (s[i] != aux.back()) aux += s[i];
  dp[0][0] = 1;
  for (int i = 0; i < 5005; i++) acum[0][i] = acum[i][0] = 1;
  for (int i = 1; i <= aux.size(); i++) {
    int sum = 0;
    for (int j = 1; j <= n; j++) {
      dp[i][j] = acum[i - 1][j - 1] -
                 (lst[aux[i - 1]] == 0 ? 0 : acum[lst[aux[i - 1]]][j - 1]);
      if (dp[i][j] < 0) dp[i][j] += 1000000007;
      sum += dp[i][j];
      if (sum >= 1000000007) sum -= 1000000007;
      acum[i][j] = sum + acum[i - 1][j];
      if (acum[i][j] >= 1000000007) acum[i][j] -= 1000000007;
    }
    lst[aux[i - 1]] = i;
  }
  int ans = 0;
  for (int i = 1; i <= aux.size(); i++) {
    ans += dp[i][n];
    if (ans >= 1000000007) ans -= 1000000007;
  }
  printf("%d\n", ans);
  return 0;
}
