#include<iostream>
#include<cmath>
#define ll long long

using namespace std;

void FICA()
{
    ll int n,k;
    ll d = pow(10,9) + 7;

    cin>>n>>k;

    ll int A[n];

    ll int sum = 0;

    for(ll int i=0;i<n;++i){
        cin>>A[i];
        sum += A[i]; }

    if(k == 0){
        cout<<sum;
        return;
    }
    else if(n == 2){
        sum = 0;

        sum += A[0] * (k+1);
        sum += A[1] * (k+1);

        cout<<sum%d<<endl;

        return;
    }
    else{
           ll int razlika = abs(n - (n-1)*2);
           ll int mnozenje = n;
           ll int i,j;
            sum = 0;
        for(i=0,j=n-1;i < j;++i,--j){
            sum += A[i] * mnozenje;
            sum += A[j] * mnozenje;
            mnozenje += razlika;
            razlika /= 2;
        }
        if(i == j){
            sum += A[i] * mnozenje;
        }

        cout<<sum%d<<endl;
    }
}

int main(void)
{
    FICA();
    return 0;
}