#include #define all(x) (x).begin(), (x).end() typedef long long ll; #define MOD 1000000007 using namespace std; #define MAX 1000000 ll fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for(int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll COM(ll n, ll k) { if(n < k) return 0; if(n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main() { ll n, k; cin >> n >> k; vector a(n + 1); for(int i = 1; i <= n; i++) { cin >> a[i]; } ll ans = 0; COMinit(); for(int i = 1; i <= n; i++) { ans += a[i] * ((COM(k + i - 1, i - 1) * COM(k + n - i, n - i)) % MOD) % MOD; ans %= MOD; } cout << ans << endl; }