#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define FOR(n) for(int i = 0; i < n; i++)
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pdd pair<double, double>
#define mii map<int,int>
#define C const int
using namespace std;
C MOD = 1e9 + 7;
C mxn = 2e5;
int f(int n, int a[], int k, int l, int r){
    if(k==0){
        int s = 0;
        for(int i = l; i<= r; i++){
            s+=a[i];
            if(s>MOD) s = s%MOD;
        }
        return s;
    }
    int s = 0;
    for(int i = 0; i < n; i++){
        for(int j = i; j < n; j++){
            s+=f(n,a,k-1,i,j);
            if(s>MOD) s = s%MOD;
        }
    }
    return s;
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);

    int n,k; cin >> n >> k;

    int a[mxn];
    FOR(n) cin >> a[i];
    if(k==1)
    {
        int s = 0;
        FOR(n){
            s+= (i+1)*(n-i)*a[i];
            if(s>MOD) s = s % MOD;
        }
        cout << s << "\n";
    }
    else
    cout << f(n,a,k,0,n-1);



}