#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pb push_back
#define endl "\n"
#define amfetamin ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cerr.tie(0);
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
const int N = 2005;
const ll M = 1e9 + 7;
const ll INF = 1e9 + 7;
ll suf[N][N];
ll col[N][N];
ll pref[N];
ll ct[N][N];
ll a[N];

int main()
{
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++)
{
    cin >> a[i];
    pref[i] = pref[i - 1] + a[i];
}
if (k == 0)
{
    ll sol = pref[n] - pref[0];
    sol %= M;
    cout << sol;
    return 0;
}

for (int l = 1; l <= n; l++)
    for (int r = l; r <= n; r++)
        ct[l][r] = 1;
for (int r = 1; r <= n; r++)
    for (int l = 1; l <= r; l++)
    {
        if (l == 1)
            col[1][r] = ct[1][r];
        else
            col[l][r] = col[l - 1][r] + ct[l][r];
    }
for (int l = 1; l <= n; l++)
    for (int r = n; r >= l; r--)
    {
        if (r == n)
            suf[l][n] = ct[l][n];
        else
            suf[l][r] = suf[l][r + 1] + ct[l][r];
    }
k--;

while (k--)
{
    for (int i = 1; i <= n; i++)
    {
        int r = i;
        int l = 1;
        ll sum = 0;
        while (r <= n)
        {
            ll old = col[l][r];
            sum += suf[l][r];
            ct[l][r] = sum;
            sum -= old;
            r++;
            l++;
        }
    }

    for (int l = 1; l <= n; l++)
        for (int r = l; r <= n; r++)
            col[l][r] %= INF;

    for (int r = 1; r <= n; r++)
        for (int l = 1; l <= r; l++)
        {
            if (l == 1)
                col[1][r] = ct[1][r];
            else
                col[l][r] = col[l - 1][r] + ct[l][r];
            col[l][r] %= INF;
        }

    for (int l = 1; l <= n; l++)
        for (int r = n; r >= l; r--)
        {
            if (r == n)
                suf[l][n] = ct[l][n];
            else
                suf[l][r] = suf[l][r + 1] + ct[l][r];
            suf[l][r] %= INF;
        }
}
ll sol = 0;
for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++)
    {
        if (ct[i][j] < 0)
            ct[i][j] += INF;
        sol += (ct[i][j] % M) * (pref[j] - pref[i - 1]);
        sol %= M;
    }
cout << sol;


}