#include <bits/stdc++.h>
 
using namespace std;
 
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define vt vector
#define all(x) (x).begin(), (x).end()
#define sp ' '
#define ar array
#define fi first
#define se second
#define ends "\n"
#define fu function
 
const long long MOD=1e9+7;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
void DBG() {
    cerr << "]" << endl;
}
template<class H, class... T> void DBG(H h, T... t) {
    cerr << to_string(h);
    if(sizeof...(t))
        cerr << ", ";
    DBG(t...);
}
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
 
 
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
 	int N, K; cin >> N >> K;
 	vector<ll> A(N+1), cnt(N+1);
 	for(int i=1; i<=N; ++i){
 		cin >> A[i];
 		cnt[i]=A[i]+cnt[i-1];
 	}
 	if(N>301){
 		cout << "Nece te mucimo" << ends;
 		exit(0);
 	}

 	map<pair<int, int>, pair<ll, ll>> mp;
 	mp[{1, N}].fi=1;
 	for(int f=0; f<K; ++f){
 		for(auto&x:mp){
 			for(int i=x.fi.fi; i<=x.fi.se; i++){
 				for(int j=i; j<=x.fi.se; j++){
 					if(i==x.fi.fi&&j==x.fi.se)continue;
 					mp[{i, j}].se=(mp[{i, j}].se + mp[x.fi].fi)%MOD;
 				}
 			}
 		}
 		for(auto&x:mp){
 			x.se.fi+=x.se.se;
 			x.se.fi%=MOD;
 			x.se.se=0;
 		}
 	}

 	ll ans=0;
 	for(auto&x:mp){
 		ans=(ans + ((((cnt[x.fi.se]-cnt[x.fi.fi-1]) % MOD)*((x.se.fi) % MOD)) % MOD) ) % MOD;
 	}
 	cout << ans << ends;
}