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

namespace takmicenje4._2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, k,ma=0,mi=0,a=0;
            UInt64 s = 0;
            string []nz = Console.ReadLine().Split();
            n = int.Parse(nz[0]);
            k = int.Parse(nz[1]);
            string[] nz1 = Console.ReadLine().Split();
            UInt64[] niz = new UInt64[n];
            int[] niz1 = new int[2 * n];
            int[] niz2 = new int[2 * n];
            int[] stepen = new int[n];
            for (int i=0;i<n;i++)
            {
                niz[i] = UInt64.Parse(nz1[i]);
            }
            if (k == 0)
            {
                for (int i = 0; i < n; i++)
                    s+=niz[i];
            }
            else
            {
                if (k == 1)
                {
                    ma = n; mi = 1;
                    for (int i = 0; i < 2 * n; i += 2)
                    {
                        niz1[i] = ma;
                        niz1[i + 1] = mi;
                        niz2[i] = ma;
                        niz2[i + 1] = mi;
                        ma--;
                        mi++;
                    }
                }
                else
                {
                    ma = n; mi = 1;
                    for (int i = 0; i < 2 * n; i += 2)
                    {
                        niz1[i] = ma;
                        niz1[i + 1] = mi;
                        niz2[i] = ma;
                        niz2[i + 1] = mi;
                        ma--;
                        mi++;
                    }
                    for (int i = 2; i < k + 1; i++)
                    {
                        for (int j = 0; j < 2 * n; j++)
                        {
                            niz1[j] *= niz2[j];
                        }
                    }
                }
                a = 0;
                s = 0;
                for (int i = 0; i < 2 * n; i += 2)
                {
                    stepen[a] = niz1[i] * niz1[i + 1];
                    a++;
                }
                for (int i = 0; i < n; i++)
                {
                    s += (niz[i] * Convert.ToUInt64(stepen[i]));
                    while (s > 1000000007)
                        s -= 1000000007;
                }
            }
            Console.WriteLine(s);
            Console.ReadLine();
        }
    }
}