#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 5050;
const long long MOD = 1000000007;
long long dp[2][MAXN][26];
long long dpSum[2][MAXN];
int ind[26];
int main() {
  int n;
  scanf("%d", &n);
  char str[MAXN];
  scanf("%s", str);
  vector<int> v;
  v.push_back(str[0] - 'a');
  char c = str[0];
  for (int i = 1; i < n; i++) {
    if (str[i] != c) {
      v.push_back(str[i] - 'a');
      c = str[i];
    }
  }
  int len = v.size();
  for (int j = 1; j <= n; j++) dp[0][j][v[0]] = 1;
  for (int j = 1; j <= n; j++) {
    for (int x = 0; x < 26; x++)
      dpSum[0][j] = (dpSum[0][j] + dp[0][j][x]) % MOD;
  }
  for (int i = 1; i < len; i++) {
    long long sum = 1;
    for (int j = 1; j <= n; j++) {
      dp[1][j][v[i]] = sum;
      sum = (sum + dpSum[0][j] - dp[0][j][v[i]] + MOD) % MOD;
    }
    for (int j = 1; j <= n; j++) {
      dpSum[1][j] = (dpSum[0][j] - dp[0][j][v[i]] + dp[1][j][v[i]] + MOD) % MOD;
    }
    for (int j = 1; j <= n; j++) {
      dp[0][j][v[i]] = dp[1][j][v[i]];
      dpSum[0][j] = dpSum[1][j];
    }
  }
  cout << dpSum[0][n];
}
