#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);
    int n; string s;
    cin >> n >> s;

    vector<long long> v(26);
    v[s[0] - 'A']++;
    for (int i = 1; i < n; i++) {
        if (s[i - 1] <= s[i]) {
            v[s[i] - 'A']++;
        }
    }

    long long mogucnosti = 1;
    for (int i = 0; i < 26; i++) {
        mogucnosti *= v[i] > 1 ? v[i] : 1;
    }

    cout << mogucnosti % (long long)1000000007;

    return 0;
}