#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,k,z,j;
cin >> n >> k;
ll a[n],zbir;
zbir =0;
j=z=0;
for(int i=0;i<n;++i){
    cin >> a[i];
}
while(k--){
   for(int i=0;i<n;++i){
        zbir = (zbir+(a[i]*(n-i)*(i+1)))%1000000007;
        a[i] = zbir;
        zbir = 0;
   }
}
for(int i=0;i<n;++i){
    zbir=(zbir+(a[i]))%1000000007;
}
cout << zbir;
return 0;
}