#include #include using namespace std; #define ll long long #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++) #define revrep(i,n) for(int (i)=(n)-1;i>=0; i--) ll modpow(ll b, ll e, ll p) { if(e==0) return 1; if(e%2==0) { ll t = modpow(b,e/2,p); return (t*t)%p; } return (b*modpow(b,e-1,p))%p; } ll modinv(ll n, ll p) { return modpow(n,p-2,p); } ll modcomb(ll n, ll k, ll p) { // O(k) ll ans=1; for(ll i=n; i>=n-k+1; i--) { ans*=i; ans%=p; } for(ll i=1; i<=k; i++) { ans*=modinv(i,p); ans%=p; } return ans; } // O(1) nCk calculation const ll p = 1e9+7; const int MX = 1000000; ll modFact[MX+1]; ll modFactInv[MX+1]; void precalc() { modFact[0]=1; modFactInv[0]=1; repeat(i,1,MX+1) { modFact[i]=(modFact[i-1]*i)%p; modFactInv[i]=modinv(modFact[i],p); } } ll fastModComb(ll n, ll k, ll p) { // call precalc() first. ll ret=modFact[n]; ret=ret*modFactInv[n-k]; ret%=p; ret=ret*modFactInv[k]; ret%=p; return ret; } int main() { cin.tie(0); ios::sync_with_stdio(false); cout<::max_digits10); int n; cin>>n; vector a(n); rep(i,n)cin>>a[i]; if(n==1) { cout << a[0] << endl; return 0; } precalc(); ll ans=0; rep(i,n) { ans+=fastModComb(n-1,i,p)*a[i]; ans%=p; } cout <