#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int maxn=2e5+10;
int pref[maxn];
typedef long long ll;
ll f(int a[],int l,int r,int k)
{
    ll ans=0;
    if(k==0)
    {
        if(l==0)return pref[r];
        else return (pref[r]-pref[l-1]+mod)%mod;
    }

    for(int i=l;i<=r;++i)
    {
        for(int j=i;j<=r;++j)
        {
            ans=(ans+f(a,i,j,k-1))%mod;
        }
    }
    return ans;
}

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    cin>>a[0];
    pref[0]=a[0];
    for(int i=1;i<n;++i)
    {
        cin>>a[i];
        pref[i]=(a[i]+pref[i-1])%mod;
    }
    cout<<f(a,0,n-1,k);
}