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