using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.SymbolStore;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Net.WebSockets;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Schema;


namespace ConsoleApplication2
{

    class Program
    {
        static void zbir(List<long> a, ref long zb)
        {
            for(int i=0;i<a.Count;i++)
            {
                for(int j=i;j<a.Count;j++)
                {
                    for(int k=i;k<(i+j-i+1);k++)
                    {
                        zb += a[k];
                        zb = zb % 1000000007;
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            long n = long.Parse(s[0]);
            long k = long.Parse(s[1]);
            var a = Console.ReadLine().Split().Select(long.Parse).ToList();
            long zb = 0;
            if(k==0)
            {
                for (int i = 0; i < n; i++)
                {
                    zb = zb + a[i];
                    zb = zb % 1000000007;
                } 
                Console.WriteLine(zb % 1000000007);
                
            }
            else if(k>0)
            {
                zbir(a, ref zb);
                zb = zb % 1000000007;
                Console.WriteLine(zb % 1000000007);
            }
        }

    }
}