#include <iostream>
#include <cmath>

int main() {
	std::ios_base::sync_with_stdio(false);

	int N;
	std::cin >> N;

	std::string S;
	std::cin >> S;

	const std::string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	const unsigned int moduo = std::pow(10, 9) + 7;

	unsigned int combinations = 1;

	int letter = 0;
	char prev_letter = '\0';
	int seg_len = 0;
	for (int i = 0; i <= N; ++i) {
		if (i != N && S[i] == prev_letter) {
			++seg_len;
		}
		else {
			if (i > 0 && S[i - 1] == alphabet[letter]) {
				++letter;
				combinations *= seg_len;

				if (combinations > moduo) combinations -= moduo;
			}

			seg_len = 1;

		}

		if (i != N) prev_letter = S[i];
	}

	std::cout << combinations;

	return 0;
}