using System;
using System.Text;
namespace takmicenje_zad_resi
{
    class Program
    {
        static int d(int[,] v, int[] a, int[] a1, int i, int i1)
        {
            if (i1 == -1) return c(v, a, a1, i + 1, i1);
            if (v[i, i1] == 0) v[i,i1] = c(v, a, a1, i + 1, i1) + 1;
            return v[i, i1] - 1;
        }
        static int c(int[,] v, int[] a, int[] a1, int i, int i1)
        {
            int bm = 0;
            if (i1 == 25) return 1;
            while (i < a.Length && i1 == a[i]) i++;
            if (i > a1[i1 + 1]) return 0;
            if (i >= a.Length) return 0;
            bm += d(v, a, a1, i, i1);
            if (a[i] == i1 + 1) bm += d(v, a, a1, i, i1 + 1);
            if (bm > Math.Pow(10, 9) - 7) bm = bm - (int)Math.Pow(10, 9) - 7;
            return bm;
        }
        static int b(string s, int n, int[,] v)
        {
            byte[] ab = Encoding.ASCII.GetBytes(s);
            int[] a = new int[n];
            int[] a1 = new int[26];
            {
                int i = 0;
                foreach (byte ba in ab) { a[i] = Convert.ToInt32(ba) - 65; a1[a[i]] = i; i++; }
            }
            return c(v, a, a1, 0, -1);
        }
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int[,] v = new int[n, 26];
            Console.WriteLine(b(s, n, v));
        }
    }
}