#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	int num[26] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, n;
	int test_br;
	cin >> n;
	char tekst[1000000];
	for (int i = 0;i < n;i++)
	{
		cin >> tekst[i];
	}
	
	int counter = -1;
	for (int i = 0;i < n;i++)
	{
		int tren= (int(tekst[i]) - 65);
		
		if (tren == counter)
		{
			num[tren]++;
		}
		else if(tren>counter)
		{
			num[tren]++;
			counter++;
		}
	}
	int ostatak[11] = {1,0,0,0,0,0,0,0,0,0,0};
	
	for (int i = 0;i < 26;i++)
	{
		if (num[i] != 1)
		{
			test_br = 0;
			for (int j = 0;j < 10;j++)
			{
				ostatak[j] *= num[i];
			}
			for (int j = 0;j < 10;j++)
			{
				if (ostatak[j] / 10 != 0)
				{
					ostatak[j + 1] += ostatak[j] / 10;
					ostatak[j] %= 10;
				}
				test_br += (ostatak[j] * pow(10, j));
			}
			if (test_br > 1000000007)
			{
				do
				{
					test_br -= 1000000007;
				}while(test_br>100000007);
				test_br += 1000000007;
				for (int j = 0;j < 10;j++)
				{
					ostatak[j] = test_br % 10;
					test_br /= 10;
				}
			}
		}
	}

	test_br = 0;
	for (int j = 0;j < 10;j++)
	{
		test_br += (ostatak[j] * pow(10, j));
	}
	cout << test_br << endl;
	return 0;
}