#include<iostream>
#include<vector>
using namespace std;
void unos(vector<int>&v,int n)
{
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
}
int bag(vector<int>v,int n,int k)
{
    if(k==0)
    {
        int s=0;
        for(int i=0;i<n;i++)
        {
            s+=v[i];
        }
        return s%10000007;
    }
    if(n%2==0)
    {
        int i=1,s=0,x=0;
        while(i<=n/2)
        {
            s+=i*(n-(i-1))*v[x];
            i++;
            x++;
        }
        i--;
        while(i>0)
        {
            s+=i*(n-(i-1))*v[x];
            i--;
            x++;
        }
        return s%10000007;
    }
    else
    {
        int i=1,s=0,x=0;
        while(i<=n/2+1)
        {
            s+=i*(n-(i-1))*v[x];
            i++;
            x++;
        }
        i-=2;
        while(i>0)
        {
            s+=i*(n-(i-1))*v[x];
            i--;
            x++;
        }
        return s%10000007;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    int n,k;
    cin>>n;
    cin>>k;
    vector<int>v(n);
    unos(v,n);
    cout<<bag(v,n,k);
    return 0;
}