using System;
using System.Linq;

namespace peti_zadatak_suma_i_to
{
    public static class Extensions
    {
        public static T[] SubArray<T>(this T[] array, int offset, int length)
        {
            return array.Skip(offset)
                        .Take(length)
                        .ToArray();
        }
    }
    class Program
    {
        static int funk_f(int k, int[]a)
        {
            int f = 0;
            if (k == 0)
            {

                for (int i = 0; i < a.Length; i++)
                {
                    f += a[i];
                }
            }
            if(k>0)
            {
                for (int i = 0; i < a.Length; i++)
                {
                    int f1 = 0;
                    for (int j = i; j < a.Length; j++)
                    {
                        f1 += funk_f(k - 1, a.SubArray(i, j-i+1));
                    }
                    f += f1;
                }
            }
            return f;

        }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]); int k = int.Parse(s[1]);
            int[] a = new int[n];
            s = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(s[i]);
            }
            int f = funk_f(k, a);
            Console.WriteLine((f % 1000000007).ToString());
        }
    }
}