#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<vector<ll>> dpp(26,vector<ll>());
	/*string s = string(n,'a');
	for (size_t i = 0; i < n; i++)
		s[i] = 'A' + rand() % 26;*/
	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 i = 0; i < 26; i++)
	{
		sort(char_position_map[i].begin(), char_position_map[i].end());
		dpp[i] = vector<ll>(char_position_map[i].size(),1);
	}
	long long num_choices = 1;
	for (int i = 0; i < char_position_map[0].size(); i++)
	{
		dpp[0][i] = num_choices;
		num_choices++;
	}

	for (int current_char = 1; current_char < 26; current_char++)
	{
		int previous_char = current_char - 1;
		ll prefix_sum = 0;
		for (int i = 0; i < char_position_map[current_char].size(); i++)
		{
			int current_char_position = char_position_map[current_char][i];
			ll current_solution = 0;
			auto it = lower_bound(char_position_map[previous_char].begin(), char_position_map[previous_char].end(), current_char_position);

			int position = it - char_position_map[previous_char].begin();
			position--;
			if (position >= 0)
			{
				current_solution = dpp[previous_char][position];
			}	
			prefix_sum += current_solution;
			prefix_sum %= mod;
			dpp[current_char][i] = prefix_sum;
		}
	}

	cout << dpp[25].back() << "\n";
	return 0;
}