#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<vector<int>> char_position_map(26,vector<int>());
	vector<ll> dp(n,1);
	string s; cin >> s;
	for (int i = 0; i < n; i++)
	{
		char c = s[i];
		char_position_map[c-'A'].push_back(i);
	}
	for (int current_char = 1; current_char < 26; current_char++)
	{
		int previous_char = current_char - 1;
		for (int current_char_position: char_position_map[current_char])
		{
			ll current_solution = 0;
			for (int previous_char_position : char_position_map[previous_char])
			{
				if (previous_char_position < current_char_position)
				{
					current_solution += dp[previous_char_position];
					current_solution %= mod;
				}
			}
			dp[current_char_position] = current_solution;
		}
	}

	ll solution = 0;
	for (int position: char_position_map[25])
	{
		solution += dp[position];
		solution %= mod;
	}
	cout << solution << "\n";
	return 0;
}