from math import factorial N = int(input()) A = list(map(int,input().split())) z = factorial(N-1) % (10**9+7) ans = A[0] + A[-1] for i in range(1,N-1) : x = math.factorial(i) % (10**9+7) y = math.factorial(N-1-i) % (10**9+7) xy = (x*y) % (10**9+7) comb = z//(x*y) ans += comb*A[i] print(ans)