#include <bits/stdc++.h>
using namespace std;
long long valChr[1000001];
map<char,long long>sum;
int main()
{
	int n;
	scanf("%i",&n);
	char s[n+1];
	scanf("%s",&s);
	if(n<26)
	{
		printf("0\n");
	}
	else if(n==26)
	{
		bool broke=false;
		for(int i=0;i<n-1;i++)
		{
			if(s[i]>=s[i+1])
			{
				printf("0\n");
				broke=true;
				break;
			}
		}
		if(broke==false)
		{
			printf("1\n");
		}
	}
	else if(n==27)
	{
		map<char,int>mapa;
		bool broke=false;
		for(int i=0;i<n;i++)
		{
			mapa[s[i]]++;
		}
		for(int i=65;i<=90;i++)
		{
			char ascii=i;
			if(mapa[ascii]==0)
			{
				printf("0\n");
				broke=true;
				break;
			}
		}
		if(broke==false)
		{
			bool brokeee=false;
			for(int i=0;i<n-1;i++)
			{
				if(s[i]>s[i+1] && mapa[s[i+1]]!=2 && mapa[s[i]]!=2)
				{
					printf("0\n");
					brokeee=true;
					break;
				}
			}
			if(brokeee==false)
			{
				bool brokee=false;
				for(int i=0;i<n-1;i++)
				{
					if(s[i]==s[i+1])
					{
						printf("2\n");
						brokee=true;
						break;
					}
				}
				if(brokee==false)
				{
					printf("1\n");
				}
			}
		}
	}
	else
	{
		map<char,int>mapa;
		bool broke=false;
		for(int i=0;i<n;i++)
		{
			mapa[s[i]]++;
		}
		for(int i=65;i<=90;i++)
		{
			char ascii=i;
			if(mapa[ascii]==0)
			{
				printf("0\n");
				broke=true;
				break;
			}
		}
		if(broke==false)
		{
			map<char,vector<int>>indChr;
			for(int i=n-1;i>=0;i--)
			{
				if(s[i]=='Z')
				{
					valChr[i]=1;
					indChr[s[i]].push_back(i);
					sum[s[i]]=(sum[s[i]]+valChr[i])%1000000007;
				}
				else
				{
					valChr[i]=sum[s[i]+1]%1000000007;
					indChr[s[i]].push_back(i);
					sum[s[i]]=(sum[s[i]]+valChr[i])%1000000007;
				}
			}
			long long r=0;
			for(int i=0;i<n;i++)
			{
				if(s[i]=='A')
				{
					r=(r+valChr[i])%1000000007;
				}
			}
			printf("%lld\n",r);
		}
	}
	return 0;
}