#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int lint; #define rep(i, n) for (lint i = 0; i < n; i++) #define sort(v) sort((v).begin(), (v).end()) #define reverse(v) reverse((v).begin(), (v).end()) #define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge) #define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge) #define mp make_pair #define enld endl lint power(lint x, lint n, lint m) { //(x^n)%mを返す lint res = 1; x %= m; while (n > 0) { if (n % 2 == 1) { res = res * x % m; } x = x * x % m; n /= 2; } return res; } lint invmod(lint n, lint m) { //nの逆元を返す lint ret = 0; ret = power(n, m - 2, m); return ret; } lint comb(lint n, lint k, lint m) { //nCk%MODを返す //O(k) lint ans = 1; rep(i, k) { ans *= n - i; ans %= m; ans *= invmod(k - i, m); ans %= m; } return ans; } int main() { lint MOD = pow(10, 9) + 7; lint N; cin >> N; vectorA(N); rep(i, N) { cin >> A[i]; } lint ans = 0; rep(i, N) { ans += (A[i] * comb(N - 1, i, MOD))%MOD; ans %= MOD; } cout << ans << endl; }