#include<bits/stdc++.h>
#define ld double
#define ll long long
#define rg register
using namespace std;
const int Mod=1e9+7;
const ld Pai=acos(-1);
const int MAXN=53e4+10;
int n,Ans,Sq=31623,Seq[MAXN],Val[MAXN],F[MAXN],G[MAXN];
int Pre1[MAXN],Pre2[MAXN],Suf1[MAXN],Suf2[MAXN],Fac[MAXN],Invf[MAXN];
struct Complex
{   ld Real,Imag;
	inline Complex(){   Real=Imag=0;   }
	inline Complex(rg ld A,rg ld B){   Real=A,Imag=B;   }
	inline Complex operator + (rg Complex S)
		{   return Complex(Real+S.Real,Imag+S.Imag);   }
	inline Complex operator - (rg Complex S)
		{   return Complex(Real-S.Real,Imag-S.Imag);   }
	inline Complex operator * (rg Complex S)
		{   return Complex(Real*S.Real-Imag*S.Imag,Real*S.Imag+Imag*S.Real);   }
}A[MAXN],B[MAXN],C[MAXN],D[MAXN],W[MAXN],H[MAXN],Zero;
inline int Read()
{   rg int a=0,c=1;   rg char b=getchar();
	while(b!='-'&&(b<'0'||b>'9'))b=getchar();
	if(b=='-')c=-1,b=getchar();
	while(b>='0'&&b<='9')a=a*10+b-48,b=getchar();
	return a*c;
}
inline int Fast(rg int Di,rg int Mi)
{   rg int Back=1;
	for(;Mi>=1;Mi>>=1,Di=1ll*Di*Di%Mod)
		if(Mi&1) Back=1ll*Back*Di%Mod;
	return Back;
}
inline int Min(rg int A,rg int B){   return A<B?A:B;   }
namespace Poly
{   int Len,Ms,Rader[MAXN];
	inline void MTT(Complex *P,rg int opt)
	{   for(rg int i=0;i<Len;i++)
			if(i<Rader[i]) swap(P[i],P[Rader[i]]);
		for(rg int i=1;i<Len;i<<=1)
			for(rg int Pos=i<<1,j=0;j<Len;j+=Pos)
				for(rg int k=0;k<i;k++)
				{   rg Complex Wi=Complex(W[Len/i*k].Real,opt*W[Len/i*k].Imag),X=P[j+k],Y=Wi*P[i+j+k];
					P[j+k]=X+Y,P[i+j+k]=X-Y;
				}
		for(rg int i=0;i<Len&&opt<0;i++) P[i].Real=(ll)(P[i].Real/Len+0.5);
	}
	inline void Prepare(rg int Lx)
	{   Ms=-1;
		for(Len=1;Len<Lx;Len<<=1) Ms++;
		for(rg int i=0;i<Len;i++) Rader[i]=(Rader[i>>1]>>1)|((i&1)<<Ms);
		for(rg int i=0;i<Len;i++) W[i]=Complex(cos(Pai/Len*i),sin(Pai/Len*i));
	}
	inline void Get_Mul(int *X,int *Y,int *Z,rg int Lx)
	{   Prepare(Lx<<1);
		for(rg int i=0;i<Len;i++) A[i]=B[i]=C[i]=D[i]=Zero;
		for(rg int i=0;i<Lx;i++) A[i].Real=X[i]/Sq,B[i].Real=X[i]%Sq,C[i].Real=Y[i]/Sq,D[i].Real=Y[i]%Sq;
		MTT(A,1),MTT(B,1),MTT(C,1),MTT(D,1);
		for(rg int i=0;i<Len;i++) H[i]=A[i]*C[i];
		MTT(H,-1);
		for(rg int i=0;i<Len;i++) Z[i]=(ll)H[i].Real%Mod*Sq%Mod*Sq%Mod;
		for(rg int i=0;i<Len;i++) H[i]=A[i]*D[i];
		MTT(H,-1);
		for(rg int i=0;i<Len;i++) Z[i]=(Z[i]+(ll)H[i].Real%Mod*Sq)%Mod;
		for(rg int i=0;i<Len;i++) H[i]=B[i]*C[i];
		MTT(H,-1);
		for(rg int i=0;i<Len;i++) Z[i]=(Z[i]+(ll)H[i].Real%Mod*Sq)%Mod;
		for(rg int i=0;i<Len;i++) H[i]=B[i]*D[i];
		MTT(H,-1);
		for(rg int i=0;i<Len;i++) Z[i]=(Z[i]+(ll)H[i].Real)%Mod;
	}
}using Poly::Get_Mul;
int main()
{   n=Read(),Fac[0]=1;
	for(rg int i=1;i<=n;i++) Seq[i]=Read();
	for(rg int i=1;i<=n+1;i++) Fac[i]=1ll*Fac[i-1]*i%Mod;
	Invf[n+1]=Fast(Fac[n+1],Mod-2);
	for(rg int i=n;i>=0;i--) Invf[i]=1ll*Invf[i+1]*(i+1)%Mod;
	for(rg int i=1;i<=n;i++) Pre1[i]=(Pre1[i-1]+Seq[i])%Mod,Pre2[i]=(Pre2[i-1]+1ll*Seq[i]*i)%Mod;
	for(rg int i=n;i>=1;i--) Suf1[i]=(Suf1[i+1]+Seq[i])%Mod,Suf2[i]=(Suf2[i+1]+1ll*Seq[i]*(n-i+1))%Mod;
	for(rg int Len=1,More;Len<=n-2;Len++)
		More=Min(Len,n-Len-1),Val[Len]=(1ll*Pre2[More]-Pre1[More]+Suf2[n-More+1]-Suf1[n-More+1]+1ll*(Pre1[n-More]-Pre1[More])*More)%Mod;
	for(rg int i=3;i<=n;i++) F[i]=1ll*Fac[i-1]*Fac[n-i]%Mod*Invf[i-3]%Mod;
	for(rg int i=0;i<=n;i++) G[i]=Invf[i];
	Get_Mul(F,G,F,n+1);
	for(rg int i=1;i<=n-2;i++) F[n-i+1]=1ll*F[n-i+1]*i%Mod*Fac[n-i-2]%Mod,Ans=(Ans+1ll*F[n-i+1]*Val[i])%Mod;
	for(rg int i=0;i<=n;i++) F[i]=G[i]=0;
	for(rg int i=1;i<=n-1;i++) Val[i]=(Pre1[i]+Suf1[n-i+1])%Mod;
	for(rg int i=1;i<=n;i++) F[i]=1ll*(i-1)*Fac[n-i]%Mod;
	for(rg int i=0;i<=n;i++) G[i]=Invf[i];
	Get_Mul(F,G,F,n+1);
	for(rg int i=1;i<=n-1;i++) F[n-i+1]=1ll*F[n-i+1]*i%Mod*Fac[n-i-1]%Mod,Ans=(Ans+1ll*F[n-i+1]*Val[i])%Mod;
	Ans=(Ans+1ll*Fac[n]*Pre1[n])%Mod,printf("%d\n",Ans);
}


Measured memory_bytes: 70912