#include using namespace std; template struct Mint { int v; Mint(int _v = 0) : v(_v) { v %= m; adjust(); } void adjust() { if (v < 0) v += m; if (v >= m) v -= m; assert(0 <= v && v < m); } Mint operator+() const { return *this; } Mint operator-() const { Mint r = Mint(0) - *this; return r.adjust(), r; } friend Mint operator+(Mint a, Mint b) { a.v += b.v; return a.adjust(), a; } Mint& operator+=(const Mint &b) { return v += b.v, adjust(), *this; } friend Mint operator-(Mint a, Mint b) { a.v -= b.v; return a.adjust(), a; } Mint& operator-=(const Mint &b) { return v -= b.v, adjust(), *this; } friend Mint operator*(Mint a, Mint b) { a.v = (int64_t) a.v * b.v % m; return a.adjust(), a; } friend Mint operator*(Mint a, int v) { return a * Mint(v); } friend Mint operator^(Mint a, int p) { int v = a.v; int r = 1; for (int i = p; i; i >>= 1) { if (i & 1) r = (int64_t) r * v % m; v = (int64_t) v * v % m; } return r; } friend Mint operator^(Mint a, Mint p) { return a^p.v; } friend Mint operator/(Mint a, Mint b) { return a * (Mint(b.v)^(m-2)); } friend ostream& operator<<(ostream &os, Mint a) { return os << a.v, os; } }; template struct Factorial { vector> fac, ifac; Factorial() : fac(MAXN + 1), ifac(MAXN + 1) { fac[0] = Mint(1); for (int i = 1; i <= MAXN; ++i) fac[i] = fac[i - 1] * i; ifac[MAXN] = Mint(1) / fac[MAXN]; for (int i = MAXN; i; --i) ifac[i - 1] = ifac[i] * i; } Mint factorial(int n) { return fac[n]; } Mint binomial(int a, int b) { return fac[a] * ifac[b] * ifac[a - b]; }; }; int main() { ios::sync_with_stdio(false); int N; { cin >> N; } vector A(N); { for (int i = 0; i < N; ++i) cin >> A[i]; } const int M = 1e9 + 7; Mint res; { Factorial ft; for (int i = 0; i < N; ++i) { res = res + ft.binomial(N - 1, i) * A[i]; } } cout << res << endl; }