nCr={} def cmb(n,r): if r==0 or r==n: return 1 if r==1: return n if (n,r) in nCr: return nCr[(n,r)] nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1) return nCr[(n,r)] N=int(input()) a=[ai*cmb(N-1,i) for i,ai in enumerate([*map(int,input().split())])] print(int(sum(a)%1000000007))