#include #include #include #define MOD 1000000007 using namespace std; template struct combination { vector fct, inv; T mod; T power(T m, T n, T mod) { if (n == 0) return 1; long res = power(m, n / 2, mod); if (n % 2) res = res * res % mod * m % mod; else res = res * res % mod; return res; } combination(int size, T newMod) { fct = vector(size + 1, 1); inv = vector(size + 1, 1); mod = newMod; for (int i = 1; i <= size; ++i) { fct[i] = fct[i - 1] * i % mod; inv[i] = power(fct[i], mod - 2, mod); } } T combi(int n, int r) { return fct[n] * inv[n - r] % mod * inv[r] % 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 % MOD; }