import sys input=sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) mod=10**9+7 def main(): mod=10**9+7 N=I() A=LI() ans=0 n=N+3 def cmb(n, r, mod): if (r < 0) or (n < r): return 0 r = min(r, n - r) return (fact[n] * factinv[r] * factinv[n-r])%mod fact=[1,1] factinv=[1,1] inv=[0,1] for i in range(2, N + 1): fact.append((fact[-1] * i) % mod) inv.append((-inv[mod % i] * (mod // i)) % mod) factinv.append((factinv[-1] * inv[-1]) % mod) for i in range(1,N-1): ans=(ans+A[i]*cmb(N-1,i,mod))%mod ans+=A[0]+A[-1] print(ans%mod) main()