#include <bits/stdc++.h>
#define endl '\n'
using namespace std;


int main() {
	//freopen("in.txt", "r", stdin);
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	long long int current = 0;
	int n;
	cin >> n;
	vector<char> v(n);
	for(int i=0; i < n; i++)
    {
        cin >> v[i];
    }
    vector<unsigned int> a(n, 1);
    for(char c = 'A'; c <= 'Z'; c++)
    {
        current = 0;
        for(int i = 0; i < n; i++)
        {
            if(v[i] == c)
            {
                current += a[i];
                current %= (1000000007);
            }
            a[i] = current;
        }
    }
    cout << current;




	return 0;
}