#include <bits/stdc++.h>
using namespace std;

#define LIMIT 1000000007

int n;
string s;

void remove_Elements()
{
    int l = 1;
    for(int i = 1; i < n; ++i) if(s[l - 1] <= s[i]){ s[l] = s[i]; l++; }
    n = l;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    cin >> s;

    remove_Elements();

    long long br_nacina = 1;
    int br = 1;

    char j = s[0];

    for(int i = 1; i < n; ++i)
    {
        if(j == s[i]) br++;
        else
        {
            j = s[i];
            br_nacina *= br;
            if(br_nacina > LIMIT) br_nacina %= LIMIT;
            br = 1;
        }
    }

    br_nacina *= br;
    br_nacina %= LIMIT;

    cout << br_nacina << endl;

    return 0;
}