#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>

int main()
{
	constexpr char firstLetter = 'A';
	constexpr char lastLetter = 'Z';
	int n;
	std::cin >> n;

	std::string stringContainer;
	std::cin >> stringContainer;
	char* str = &stringContainer[0];

	bool passed[26];
	memset(passed, false, sizeof(passed));
	std::reverse(str, str + n);

	int j = 0;
	for (int i = 0; i < n; ++i)
	{
		if (str[i] == lastLetter || passed[str[i] + 1 - firstLetter])
		{
			str[j] = str[i];
			passed[str[i] - firstLetter] |= true;
			++j;
		}
	}
	n = j;

	int counts[26];
	memset(counts, 0, sizeof(counts));
	for (int i = 0; i < n; ++i)
	{
		if (str[i] == lastLetter)
			++counts[str[i] - firstLetter];
		else
		{
			counts[str[i] - firstLetter] += counts[str[i] - firstLetter + 1];
			counts[str[i] - firstLetter] %= 1000000007;
		}
	}

	std::cout << counts[0];

	return 0;
}