#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; const ll MOD = 1000000007LL; ll extgcd(ll a, ll b, ll &x, ll &y){ ll d = a; if(b!=0){ d = extgcd(b,a%b,y,x); y -= (a/b)*x; }else{ x = 1; y = 0; } return d; } ll mod_inverse(ll a, ll m){ ll x, y; extgcd(a, m, x, y); return (m+x%m)%m; } int main(){ int N; cin >> N; vector v; rep(i,N){ ll a; cin >> a; v.push_back(a); } ll ret = 0; vector inv(N+1, 1); ll q = 1; rep(i,N-1){ q *= i+1; q %= MOD; inv[i+1] = mod_inverse(q, MOD); } rep(i,N){ ll tmp = q; tmp *= inv[i]; tmp %= MOD; tmp *= inv[N-i-1]; tmp %= MOD; ret += v[i] * tmp; ret %= MOD; } cout << ret << endl; return 0; }