#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define sz(a) a.size()
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
const int inf = 2e9;
const ll linf = 4e18;
vector<ll> a;
int dp[310][310][310];
int cnt[310];
int f(int l, int r, int k)
{
    if (dp[l][r][k])return dp[l][r][k];
    int s = 0;
    if (!k) {
        for (int i = l; i <= r; i++) {
            s += a[i];
            cnt[i]++;
        }
        return dp[l][r][k] = s;
    }
    for (int i = l; i <= r; i++) {
        for (int j = i; j <= r; j++) {
            s += f(i, j, k - 1);
        }
    }
    dp[l][r][k] = s;
    return s;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
    ll n, k;
    cin >> n >> k;
    a.resize(n);
    ll s = 0;
    for (ll i = 0; i < n; i++)cin >> a[i];
    if (k == 0) {
        for (ll i = 0; i < n; i++)s += a[i];
        cout << s % mod;
        return 0;
    }
    if (k == 1) {
        for (ll i = 0; i < n; i++) {
            s += (a[i] * ((i + 1) * (n - i) % mod) % mod); s %= mod;
        }
        cout << s;
        return 0;
    }
    cout << f(0, n - 1, k);
    return 0;
}