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

namespace BUG
{
    class Program
    {
        static long fuggveny(long[] A, long k)
        {
            long x = 0;
            long n = A.Length;
            if(k==0)
            {
                for (int i = 0; i < n; i++) x += A[i];
            }
            if (k == 1)
            {
                for (int i = 0; i < n; i++) x = (x % ((int)Math.Pow(10, 9) + 7)) + (A[i] * (n - i)*(i + 1)) % ((int)Math.Pow(10,9)+7);
            }
            return x % ((int)Math.Pow(10, 9) + 7);
        }
        static void Main(string[] args)
        {
            string[] sor = Console.ReadLine().Split(' ');
            int n = int.Parse(sor[0]);
            int k = int.Parse(sor[1]);
            long[] A = new long[n];
            string[] sor2 = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++) A[i] = long.Parse(sor2[i]);
            long x = fuggveny(A,1);
            Console.WriteLine(x);
        }
    }
}