#include <iostream>
#include <string>
#include<cmath>
using namespace std;

int main()
{
  long n,k;
  cin >> n >> k;
  int a[n];
  for(long i=0;i<n;i++)
  {
      cin >> a[i];
  }
  long suma=0;
  if(k>0)
 {
    for(long i=0;i<n;i++)
    {
        suma+=a[i]*(n-i)*(i+1);
    }
    cout << suma%1000000007;
 }
 else
 {
     for(long i=0;i<n;i++)
     {
         suma+=a[i];
     }
     cout<<suma%1000000007;
 }
    
      
}