#include #define MOD ((long long)(1e9) + 7) typedef long long ll; ll fact[100005], finv[100005], inv[100005]; void init() { fact[0] = fact[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < 100005; i++) { fact[i] = fact[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } return; } long long com(int n, int k) { if (n < k) { return 0; } if (n < 0 || k < 0) { return 0; } return fact[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main() { init(); ll n; ll a[100005]; ll ans = 0; scanf("%lld", &n); for (int i = 1; i <= n; i++) { scanf("%lld", &a[i]); } ans = a[1] + a[n]; ans = ans % MOD; for (int r = 2; r < n; r++) { ans = ans + a[r] * com(n - 1, r - 1); ans % MOD; } printf("%lld\n", ans); return 0; }