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

namespace ConsoleApplication103
{
    class Program
    {
        static int zbir(int[] a, int k,int n)
        {
            int zb = 0;
            if (k == 0)
            {
                for (int i = 0; i < n; i++)
                {
                    zb += a[i];
                }
                
            }
            else
            {
                for (int i = 0; i < n; i++)
                {
                   
                    for (int j = i; j < n; j++)
                    {
                        int[] b = new int[j-i+1];
                        for (int t = 0; t < j - i + 1; t++)
                        {
                            b[t] = a[i+t];
                        }
                        zb+=zbir(b,k-1,j-i+1);
                    }
                }
            }
            return zb;
        }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = Convert.ToInt32(s[0]);
            int k = Convert.ToInt32(s[1]);
            string[] t = Console.ReadLine().Split();
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = Convert.ToInt32(t[i]);
            }
           Console.WriteLine(zbir(a, k, n)%(1000000007));
           
        }
    }
}