#include <bits/stdc++.h>
#include <iostream>

using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;

const int mxN = 3 * 1e5;

ll A[mxN];

ll dp[63][2001][2001];

ll f(int x, int a, int b)
{
    if(x < 50 && a < 2001 && b < 2001)
    {
        if(dp[x][a][b] != 0)
        {
            return dp[x][a][b];
        }
    }
    ll ans = 0;
    if(x == 0)
    {
        for (int i=a; i<b; i++)
        {
            ans += A[i] % mod;
            ans %= mod;
        }
    }
    else
    {
        for(int i = a; i < b; i++)
        {
            for(int j = i; j < b; j++)
            {
                ans += f(x - 1, i, j + 1) % mod;
                ans %= mod;
            }
        }
    }
    if(x < 50 && a < 2001 && b < 2001)
    {
        dp[x][a][b] = ans;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    if(k == 1)
    {
        ll ans = 0;
        for (int i=0; i<n; i++)
            ans += (A[i] * (i+1) * (n-i));
        cout << ans;
    }
    else
    {
        cout << f(k, 0, n);
    }
}