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

namespace ConsoleApp3
{

    class Program
    {
        public static T[] Podniz<T>(T[] a, int poc, int duz)
        {
            T[] rez = new T[duz];
            Array.Copy(a, poc, rez, 0, duz);
            return rez;
        }
        static long F(int []a,int k)
        {
            long zbir = 0;
            if (k > 0)
            {
                for (int i = 0; i < a.Length; i++)
                {
                    long zbir1 = 0;
                    for (int j = i; j < a.Length; j++)
                    {
                        int[] a1 = Podniz(a, i, j - i + 1);
                        zbir1 += F(a1, k - 1);
                    }
                    zbir += zbir1;
                }
            }
            if (k == 0)
            {
                for (int i = 0; i < a.Length; i++)
                {
                    zbir += a[i];
                }
            }
            return zbir;
        }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int k = int.Parse(s[1]);
            string[] st = Console.ReadLine().Split();
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(st[i]);
            }
            long zbir = F(a,k)%100000007;
            Console.WriteLine(zbir);
        }
    }
}