N=int(input()) a=list(map(int,input().split())) ans=a[0]+a[N-1] b=[1 for i in range(N+1)] for i in range(1,N): b[i]=b[i-1]*(N-i)//i for i in range(1,N-1): ans+=a[i]*b[i] ans%=1000000007 print(ans % 1000000007)