#include <iostream>
#include <vector>

using namespace std;

#define pb push_back
#define x first
#define y second
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

const ll mod = 1e9 + 7;

int main()
{
    IOS;
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        if (i) a[i] = (a[i] + a[i - 1]) % mod;
    }
    vector<vector<ll> > d(n, vector<ll>(n));
    d[0][n - 1] = 1;
    while (k) {
        for (ll i = n - 2; ~i; i--) {
            for (ll left = 0; left + i < n; left++) {
                ll right = left + i;
                if (left) d[left][right] = (d[left][right] + d[left - 1][right]) % mod;
                if (right < n - 1) d[left][right] = (d[left][right] + d[left][right + 1]) % mod;
                if (left && right < n - 1) d[left][right] = (d[left][right] - d[left - 1][right + 1]) % mod;
            }
        }
        k--;
    }
    ll ans = 0;
    for (ll i = 0; i < n; i++) {
        for (ll j = i; j < n; j++) {
            ll sum = a[j];
            if (i) sum = (sum - a[i - 1]) % mod;
            ll tmp = (sum * d[i][j]) % mod;
            ans = (ans + tmp) % mod;
        }
    }
    cout << ans;
    return 0;
}