#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef pair pii; typedef long long int ll; typedef pair pll; int dx[4] = { 1,0,0,-1 }; int dy[4] = { 0,1,-1,0 }; #define MOD 1000000007 #define ARRAY_MAX 100005 const int INF = 1e9 + 7; struct Combination { vector fact, rfact; Combination(ll sz) : fact(sz + 1), rfact(sz + 1) { fact[0] = 1; for (ll i = 1; i < fact.size(); i++) { fact[i] = fact[i - 1] * i % MOD; } //逆元 rfact[sz] = inv(fact[sz]); for (ll i = sz - 1; i >= 0; i--) { rfact[i] = rfact[i + 1] * (i + 1) % MOD; } } ll inv(ll x){ return pow(x, MOD - 2); } ll pow(ll x, ll n){ ll ret = 1; while (n > 0) { if (n & 1) (ret *= x) %= MOD; (x *= x) %= MOD; n >>= 1; } return (ret); } ll P(ll n, ll r){ if (r < 0 || n < r) return (0); return (fact[n] * rfact[n - r] % MOD); } ll C(ll p, ll q){ if (q < 0 || p < q) return (0); return (fact[p] * rfact[q] % MOD * rfact[p - q] % MOD); } ll H(ll n, ll r){ if (n < 0 || r < 0) return (0); return (r == 0 ? 1 : C(n + r - 1, r)); } }; int main() { ios::sync_with_stdio(false); cin.tie(0); ll n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } Combination cb(n + 1); ll ans = 0; for (ll i = 0; i < n; i++) { ans += a[i] * cb.C(n - 1, i); ans %= MOD; } cout << ans << endl; return 0; }