#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace atcoder; using Graph = vector>; using ll = long long; typedef pair P_ll; typedef pair P; const ll INF_ll = 1e17; const int INF = 1e8; template bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } template using min_priority_queue = priority_queue, greater>; using mint = modint1000000007; map mp; mint nCr(ll n, ll r) { P_ll key = {n, r}; if (mp.count(key)) return mp[key]; if (r == 0 or r == n) { mint mt = 1; return mt; } if (r == 1 or r == n - 1) { mint mt = n; return mt; } // return mp[key] = nCr(n,r-1) * (n-r+1) / r; return mp[key] = nCr(n - 1, r) * n / (n - r); } int main() { ll N, K; cin >> N >> K; vector A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } modint1000000007 ans = 0; for (int i = 0; i < N; i++) { ans += nCr(K + i, K) * nCr(N - i + K - 1, K) * A[i]; } cout << ans.val() << endl; return 0; }