/* -*- coding: utf-8 -*- * * 797.cc: No.797 Noelちゃんとピラミッド - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 100000; const int MOD = 1000000007; /* typedef */ typedef long long ll; /* global variables */ ll cs[MAX_N]; /* subroutines */ ll powmod(ll a, int n) { // a^n % MOD ll pm = 1; while (n > 0) { if (n & 1) pm = (pm * a) % MOD; a = (a * a) % MOD; n >>= 1; } return pm; } /* main */ int main() { int n; scanf("%d", &n); int m = n - 1; cs[0] = cs[m] = 1; for (int i = 1; i * 2 <= m; i++) cs[i] = cs[m - i] = cs[i - 1] * (m + 1 - i) % MOD * powmod(i, MOD - 2) % MOD; ll sum = 0; for (int i = 0; i < n; i++) { ll ai; scanf("%lld", &ai); sum = (sum + ai * cs[i] % MOD) % MOD; } printf("%lld\n", sum); return 0; }