#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	long long int n;
	cin >> n;
	vector<char> v;
	int p[26] = {0};
	char c;
	for(int i=0; i<n; i++){
		cin >> c;
		v.push_back(c);
	}
	char u = v[0];
	long long int br = 0, pr = 1;
	for(long long int i=0; i<v.size(); i++){
		if(v[i]==u)
			br++;
		if(v[i+1]!=v[i]){
			if(p[int(v[i])-65]==0)
				p[int(v[i])-65] = br;
			br = 0;
			u = v[i+1];
		}	
	}
	long long int j = 1, m = 1000000007;
	for(int i=0; i<26; i++){
		j = (j*p[i]) % m;		
	}
	cout << j;
}