#include<bits/stdc++.h>
#define IL inline
#define RG register
#define _ 400005
#define ll long long
using namespace std ;

IL ll gi(){
    ll data = 0 , m = 1; char ch = 0;
    while(ch!='-' && (ch<'0'||ch>'9')) ch = getchar();
    if(ch == '-'){m = 0 ; ch = getchar() ; }
    while(ch >= '0' && ch <= '9'){data = (data<<1) + (data<<3) + (ch^48) ; ch = getchar(); }
    return (m) ? data : -data ; 
}

const long long mod = 1000000007 ; 
const long double PI = acos(-1.0);
IL ll Power(ll bs,ll js){
    RG ll S = 1 , T = bs;
    while(js){if(js&1)S=S*T%mod; T=T*T%mod; js>>=1;}
    return S;
}
struct Complex{       
    long double r,i;
    IL Complex(){r = 0; i = 0;}
    IL Complex(RG long double a,RG long double b){r = a; i = b;}
    IL Complex operator +(Complex B){ return Complex(r+B.r,i+B.i); }
    IL Complex operator -(Complex B){ return Complex(r-B.r,i-B.i); }
    IL Complex operator *(Complex B){
        return Complex(r*B.r-i*B.i , r*B.i+i*B.r);
    }
};
Complex f1[_],f2[_],f3[_],f4[_],X,Y,g1[_],g2[_],g3[_]; 
ll Ret[_],N,M,n,m,pre[_],g[_],Ans,rev[_],Fac[_],inv[_],IFac[_],Val[_],Base ; 

IL void FFT(Complex *P , int opt){
    for(RG int i = 0; i < n; i ++)
        if(i < rev[i]) swap(P[i] , P[rev[i]]) ;  
    for(RG int i = 1; i < n; i<<=1){    
        Complex W(cos(PI/i),opt*sin(PI/i));  
        for(RG int p = i<<1 , j = 0; j < n; j += p){
            Complex w(1,0);
            for(RG int k = 0; k < i; k ++,w = w*W){
                X = P[j + k] , Y = w*P[j + k + i];
                P[j + k] = X + Y;    P[j + k + i] = X - Y;
            }
        }
    }
    if(opt == -1) for(RG int i = 0; i < n; i ++)P[i].r /= n;
}


IL void Solve() {
	Fac[0] = Fac[1] = 1 ;
	for(int i = 2; i <= N; i ++) Fac[i] = 1ll * Fac[i - 1] * i % mod ;
	inv[0] = inv[1] = 1 ; 
	for(int i = 2; i <= N; i ++) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod ; 
	IFac[0] = IFac[1] = 1 ; 
	for(int i = 2; i <= N; i ++) IFac[i] = 1ll * IFac[i - 1] * inv[i] % mod ;
	
	int l = 0 ; 
	Base = sqrt(mod) ;
	for(int i = 0; i <= N; i ++) f1[i].r = IFac[i] / Base , f2[i].r = IFac[i] % Base ;  
	for(int i = 0; i <= N; i ++) f3[i].r = Fac[N - i - 1] / Base , f4[i].r = Fac[N - i - 1] % Base ; 
	m = 2 * N ;
	for(n = 1; n <= m; n <<= 1) ++ l ; 
	for(int i = 0; i < n; i ++) rev[i] = (rev[i>>1]>>1) | ((i&1)<<(l-1)) ;
	FFT(f1 , 1) ; FFT(f2 , 1) ; FFT(f3 , 1) ; FFT(f4 , 1) ; 
	for(int i = 0; i < n; i ++) {
		g1[i] = f1[i] * f3[i] ; 
		g2[i] = f1[i] * f4[i] + f2[i] * f3[i] ;
		g3[i] = f2[i] * f4[i] ; 
	}
	FFT(g1 , -1) ; FFT(g2 , -1) ; FFT(g3 , -1) ; 
	for(int i = 0; i <= N; i ++) {
		Ret[i] = 1ll * ((long long)(g1[i].r + 0.5)) % mod * Base % mod * Base % mod ; 
		Ret[i] = (Ret[i] + 1ll * ((long long)(g2[i].r + 0.5)) % mod * Base % mod) % mod ;
		Ret[i] = (Ret[i] + (1ll * (long long)(g3[i].r + 0.5)) % mod) % mod ;
		Ret[i] %= mod ;  
	}
	
	/*
	for(int i = 0; i <= N; i ++) 
	    for(int j = 0; j <= N; j ++) 
	        Ret[i + j]  = (Ret[i + j] + 1ll * IFac[i] * Fac[N - j - 1] % mod) %mod ; 
	//for(int i = 0; i <= N; i ++) cout << Ret[i] << " " ; cout << endl ;
	*/
	
	for(int i = 0; i <= N; i ++) g[i] = 1ll * Fac[N - i] * Ret[N - i] % mod ;
	//for(int i = 1; i <= N; i ++) printf("g[%d] = %d\n" , i , g[i]) ; 
	for(int i = 2; i <= N; i ++) pre[i] = (pre[i - 1] + g[i]) % mod ;
	Ans = 0 ;	
	for(int i = 1; i <= N; i ++) {
		int len = i ;
		Ans = (Ans + 1ll * g[1] * Val[i] % mod) % mod ;
		if(len >= 2) Ans = (Ans + 1ll * pre[len] * Val[i] % mod) % mod ;
		len = N - i + 1 ;
		if(len >= 2) Ans = (Ans + 1ll * pre[len] * Val[i] % mod) % mod ; 
	}
	return ; 
}

int main() {
	N = gi() ;
	for(int i = 1; i <= N; i ++) Val[i] = gi() % mod ; 
	Solve() ; 
	cout << (Ans % mod + mod) % mod << endl ;
	return 0 ; 
}

Measured memory_bytes: 107392