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

namespace takmicenjeZadaci
{
    class Program
    {
        public static int[] DeoNiza(int[] A, int start, int length)
        {
            return A.ToList().GetRange(start, length).ToArray();
        }
        static int f(int[] A, int k)
        {
            int sum = 0;
            if(k == 0)
            {
                foreach (int number in A)
                    sum += number;
            }
            else
            {
                for(int i = 0; i < A.Length; i++)
                {
                    for(int j = i; j < A.Length; j++)
                    {
                        sum += f(DeoNiza(A, i, j - i + 1), k - 1);
                    }
                }
            }
            return sum;
        }

        static void Main(string[] args)
        {
            string[] unos1 = Console.ReadLine().Split();
            int n = int.Parse(unos1[0]);
            int k = int.Parse(unos1[1]);

            string[] unosNiza = Console.ReadLine().Split();
            int[] niz = new int[n];
            int index = 0;
            foreach(var value in unosNiza)
            {
                niz[index] = int.Parse(unosNiza[index]);
                index++;
            }
            Console.WriteLine(f(niz, k) % 1000000007);
        }
    }
}