#include <iostream> 
#include <string>
using namespace std;
long long a[10000000],N;
char c;
int tacnost=0;
long long pr=1,mn=1,c1=0,o=65;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>c;
		if(c==o)o++;
		a[i]=(long long)c;
		if(a[i]==c1)mn++;
		else{
			pr*=mn;
			mn=1;
			
		}
		if(i==N-1){
			pr*=mn;
		}
		 c1=a[i];
	}
	if(pr>10000000007){
		pr%=1000000007;
	}
	if(o==91){
		cout<<pr;
	}
	else cout<<0;
	
	return 0;
	
}