#include <bits/stdc++.h>
using namespace std;
int dp[30][5005];
char s[5005];
long long ans;
int main() {
  int n, temp;
  scanf("%d", &n);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) {
    temp = s[i] - 'a' + 1;
    ans = 1;
    for (int j = 1; j <= n; j++) {
      dp[0][j] -= dp[temp][j];
      if (dp[0][j] < 0) dp[0][j] += 1000000007;
      if (dp[0][j] > 1000000007) dp[0][j] -= 1000000007;
      dp[temp][j] = ans;
      ans += dp[0][j];
      if (ans > 1000000007) ans -= 1000000007;
      dp[0][j] += dp[temp][j];
      if (dp[0][j] > 1000000007) dp[0][j] -= 1000000007;
    }
  }
  printf("%d\n", dp[0][n]);
  return 0;
}
