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

namespace ConsoleApplication71
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] r = Console.ReadLine().Split(' ');
            int n = int.Parse(r[0]);
            int k = int.Parse(r[1]);
            int[] a = new int[n];
            string[] m = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++) 
            {
                a[i] = int.Parse(m[i]);
            }
            int s = 0;
            if (k == 0)
            {
                for (int i = 0; i < n; i++)
                            s += a[i];
           }
            while (k > 0)
            {
                for (int i = 0; i < n; i++)
                {
                    for (int j = i + 1; j <= n; j++)
                    {
                        for (int z = i; z < j; z++)
                            s += a[z];
                    }
                }
               k--; 
            }
            Console.WriteLine(s%(Math.Pow(10,9)+7));
        
        }
    }
}