#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
long long pre_sum[2][5002];
int dp[2][5002], pre[5002], last_seen[250];
int main(void) {
  ios::sync_with_stdio(false);
  int n;
  string s, s0;
  cin >> n >> s0;
  memset(&last_seen, -1, sizeof(last_seen));
  memset(&pre, -1, sizeof(pre));
  s = s0[0];
  last_seen[s0[0]] = 0;
  for (int i = 1; i < n; i++) {
    if (s0[i] != s0[i - 1]) {
      pre[s.length()] = last_seen[s0[i]];
      last_seen[s0[i]] = s.length();
      s += s0[i];
    }
  }
  dp[0][0] = 1;
  dp[1][0] = 1;
  pre_sum[1][0] = 1;
  for (int i = 0; i <= n; i++) pre_sum[0][i] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < s.length(); j++) {
      if (pre[j] == -1) {
        dp[i % 2][j] = pre_sum[(i - 1) % 2][j] % MOD;
      } else {
        dp[i % 2][j] =
            (pre_sum[(i - 1) % 2][j] - pre_sum[(i - 1) % 2][pre[j]]) % MOD;
        if (dp[i % 2][j] < 0) dp[i % 2][j] += MOD;
      }
      pre_sum[i % 2][j] = (pre_sum[i % 2][j - 1] + dp[i % 2][j]) % MOD;
    }
  }
  cout << pre_sum[n % 2][s.length() - 1];
  return 0;
}
