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

namespace _D_Bug
{
    class Program
    {
        static void Main(string[] args)
        {

            int n, k;
            long zbir = 0;

            List<int> a = new List<int>();

            var ulaz = Console.ReadLine().Split();

            n = int.Parse(ulaz[0]);
            k = int.Parse(ulaz[1]);

            ulaz = Console.ReadLine().Split();


            for (int i = 0; i < n; i++)
            {
                a.Add(int.Parse(ulaz[i]));

                if (k == 0)
                {
                    zbir += a[i];
                }
                else
                {
                    zbir += (i + 1) * (n - i) * a[i];
                }
            }

            if (k>1)
            {
                zbir = zbir * k + zbir / 2;
            }

            double x = Math.Pow(10, 9) + 7;

            zbir = zbir % (long)x; 

            Console.WriteLine(zbir);

        }
    }
}