#include <bits/stdc++.h>
using namespace std;

#define MOD 1000000007
#define ll long long

ll n, k;
ll a[200005];
ll sum[200005];
ll k1[200005];
ll res;

void solvek0()
{
    for(ll i = 1; i <= n; ++i){
        res += a[i];
        if(res >= MOD){res -= MOD;}
    }

    cout << res << "\n";
}

void solvek1()
{
    for(ll i = 1; i <= n; ++i){
        res += (((a[i] * i) % MOD) * (n - i + 1)) % MOD;
        if(res >= MOD){res -= MOD;}
    }

    cout << res << "\n";
}

void solve5(int l, int r, int k1)
{
    if(k1 == 0){
        for(int i = l; i <= r; ++i){
            res += a[i];
            if(res >= MOD){res -= MOD;}
        }
    }
    else{
        for(int i = l; i <= r; ++i){
            for(int j = i; j <= r; ++j){
                solve5(i, j, k1 - 1);
            }
        }
    }

}

void solve300()
{
    sum[1] = a[1];
    for(ll i = 2; i <= n; ++i){
        sum[i] = sum[i - 1] + a[i];
    }

    for(ll i = 0; i < k; ++i){k1[i] = 1;}
    ll cnt = k;
    res = sum[n];
    for(ll len = n - 1; len >= 1; --len){
        for(ll i = len; i <= n; ++i){
            res += (cnt * ((sum[i] - sum[i - len]) % MOD)) % MOD;
            if(res >= MOD){res -= MOD;}
        }

        for(ll i = 1; i <= k; ++i){
            for(ll j = 0; j < i; ++j){
                k1[j] += k1[i];
                if(k1[j] >= MOD){k1[j] -= MOD;}
                cnt += k1[i];
                if(cnt >= MOD){cnt -= MOD;}
            }
        }
    }

    cout << res << "\n";
}

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

    cin >> n >> k;

    for(ll i = 1; i <= n; ++i){
        cin >> a[i];
    }

    if(k == 0){
        solvek0();
    }
    else if(k == 1){
        solvek1();
    }
    else if(n <= 5 && k <= 5){
        solve5(1, n, k);
    }
    else if(n <= 300 && k <= 300){
        solve300();
    }

    return 0;
}