#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, m = 27; cin >> n;
    string s; cin >> s; n++;
    vector<vector<ll>> dp(m, vector<ll>(n));
    fill(dp[0].begin(), dp[0].end(), 1);
    for (int p = 1; p < n; p++) {
        for (int c = 1; c < m; c++) {
            if (s[p - 1] == 'A' + c - 1) {
                dp[c][p] += dp[c - 1][p - 1];
            }
            dp[c][p] += dp[c][p - 1];
            dp[c][p] %= (int)(1e9 + 7);
        }
    }
    cout << dp[m - 1][n - 1] << endl;
    return 0;
}