using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace slova
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            char[] t = s.ToCharArray();

            int br = 1;
            char prosloSlovo = t[0];
            long rez = 1 ;
            for (int i = 1; i < n; i++)
            {
                if (t[i]==prosloSlovo)
                {
                    br++;
                }
                else
                {
                    prosloSlovo = t[i];
                    rez *= br;
                    br = 1;
                }
            }

            rez *= br;
            Console.WriteLine(rez%(Math.Pow(10,9)+7));
            Console.ReadLine();
        }
    }
}