#include <iostream>

using namespace std;

int main(){
	int n;
	long abeceda[26]={0};
	
	cin>>n;
	char p;
	for(int i=0;i<n;i++){
		cin>>p;
		if(p=='A'){
			abeceda[0]++;
		}
		else{
			abeceda[p-'A']+=abeceda[p-'A'-1];
			if(abeceda[p-'A']>1000000006){
				abeceda[p-'A']-=1000000007;
			}
		}
	}
	cout<<abeceda[25];
}