#include <iostream>
#define pr pair<int,int>
#define fr first
#define sc second
using namespace std;
int MOD = 1e9+7;
pr a[26];
int main()
{
	for(int i = 0; i < 26; i++) a[i].fr = 0, a[i].sc = -1;
	int n;
	string s;
	cin >> n >> s;
	for(int i = 0; i < n; i++)
	{
		int j = s[i] - 'A';
		if(j == 0) a[0].fr++;
		else a[j].fr += a[j - 1].fr;
		a[j].sc = i;
		a[j].fr %= MOD;
	}
	cout << a[25].fr;
}