15
txxtxttxxttxtxx
 3
myw
 127
xixtxixnxixtxixlxixtxixnxixtxixoxixtxixnxixtxixlxixtxixnxixtxixhxixtxixnxixtxixlxixtxixnxixtxixoxixtxixnxixtxixlxixtxixnxixtxix
 1
a
 10
isssisssss
 2
ff
 1
z

27824
 10
 944124121
 1
 176
 1
 1

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
long long INF = 1e9;
const int N = 5031;
int n;
string st;
vector<char> blocks;
int le[N];
int same[N];
int dp[N][N], S[N][N];
int main() {
  cin >> n;
  cin >> st;
  for (int i = 0; i < st.size(); i++) {
    if (i == 0 || st[i] != st[i - 1]) blocks.push_back(st[i]);
  }
  for (int i = 'a'; i <= 'z'; i++) {
    le[i] = -1;
  }
  for (int i = 0; i < blocks.size(); i++) {
    int here = blocks[i];
    same[i] = le[here];
    le[here] = i;
  }
  for (int i = 1; i <= n; i++) {
    for (int cur_block = 0; cur_block < blocks.size(); cur_block++) {
      if (i == 1) {
        if (same[cur_block] == -1) dp[i][cur_block] = 1;
        continue;
      }
      int cl = same[cur_block] + 1;
      dp[i][cur_block] = S[i - 1][cur_block];
      if (cl > 0) dp[i][cur_block] -= S[i - 1][cl - 1];
      if (dp[i][cur_block] < 0) dp[i][cur_block] += 1000000007;
    }
    for (int cur_block = 0; cur_block < blocks.size(); cur_block++) {
      S[i][cur_block] = dp[i][cur_block];
      if (cur_block) S[i][cur_block] += S[i][cur_block - 1];
      if (S[i][cur_block] >= 1000000007) S[i][cur_block] -= 1000000007;
    }
  }
  long long ans = 0;
  for (int i = 0; i < blocks.size(); i++) {
    ans = ans + dp[n][i];
    ans %= 1000000007;
  }
  cout << ans << endl;
  cin.get();
  cin.get();
  return 0;
}
