#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    char x;
    cin >> n;
    string s = "";
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        s += x;
    }
    long long br = 1, u = 1;
    for (int i = 1; i <= n; i++)
    {
        if (s[i] == s[i-1])
            br++;
        else
        {
            u *= br;
            br = 1;
        }
    }
    u*=br;
    cout << u % (1000000000 + 7);
}