#include<iostream>
#define ll long long

using namespace std;

void FICA()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ios_base::sync_with_stdio(false);
    cout.tie(NULL);

    ll int n,k;
    ll d = 1000000007;

    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;}

        if(n == 1){
            cout<<A[0];
            return;
        }
    }
    if(k == 1){

           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;
        return;
        }

        /*else{
            int pomeraj = n-1;
            int rez = n;
        }*/

}

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