using System;

namespace _4_BUG
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] nk = Console.ReadLine().Split(' ');
            string[] As = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(nk[0]);
            long k = Convert.ToInt64(nk[1]);
            long[] A = new long[n];

            for (int i = 0; i < n; i++)
            {
                A[i] = Convert.ToInt64(As[i]);
            }

            long num = 0;

            if (k == 0)
            {
                for (int i = 0; i < n; i++)
                {
                    num += A[i];
                }
            }
            else
            {
                f(A, k-1, A.Length, ref num);
            }

            Console.WriteLine(num % 1000000007);
        }








        static void f(long[] Aa, long kindex, int n, ref long num)
        {
            long[] Ab;
            for (int i = 0; i < n; i++)
            {
                for (int j = i; j < n; j++)
                {
                    Ab = new long[j - i + 1];
                    int l = i;
                    while (l <= j)
                    {
                        Ab[j - l] = Aa[l];
                        l++;
                    }

                    if (kindex>0)
                    {
                        f(Ab, kindex - 1, Ab.Length, ref num);
                    }
                    else
                    {
                        l = i;
                        while (l <= j)
                        {
                            num+= Aa[l];
                            Ab[j - l] = Aa[l];
                            l++;
                        }
                    }
                }
            }
        }
    }
}