#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
using db = long double;
const int N = 5e5 + 5, MOD = 1e9 + 7;
using ii = pair<int, int>;
int dp[5005][5005];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 1; i < 5005; i++) dp[i][0] = 1;
  for (int i = 0; i < n; i++) {
    int l = i;
    while (l && s[l - 1] != s[i]) --l;
    for (int len = 1; len <= n; len++)
      dp[i + 1][len] =
          ((dp[i][len] + dp[i + 1][len - 1]) % MOD - dp[l][len - 1] + MOD) %
          MOD;
  }
  cout << dp[n][n] << '\n';
  return 0;
}
