#include #include #include #define MOD 1000000007 using namespace std; // vector template struct combination { vector fct, inv, finv; int mod; combination(int size, int newMod) { fct = vector(size + 1, 1); inv = vector(size + 1, 1); finv = vector(size + 1, 1); mod = newMod; for (int i = 2; i <= size; ++i) { fct[i] = fct[i - 1] * i % mod; inv[i] = mod - mod / i * inv[mod % i] % mod; finv[i] = inv[i] * finv[i - 1] % mod; } } T combi(int n, int r) { return finv[n - r] * finv[r] % mod * fct[n] % mod; } }; int main() { int N; cin >> N; vector a(N); for (long& i : a) cin >> i; long sum = 0; combination cmb(N - 1, MOD); for (int i = 0; i < N; ++i) sum = a[i] * cmb.combi(N - 1, i) % MOD + sum % MOD; cout << sum; }