N = int(input())
semi = 10**9+7
x = [int(num) for num in input().split()]
ans = 0
wa=[]
c=0
for i in range(N):
    c += x[N-i-1]
    wa.append(c)
#print(wa)

ans = 0
step = 1
for i in range(1,N):
    ans = (ans*(i) +wa[i-1]*step)#%semi
    step *= i
 #   print(ans)

ans -=sum(x[0:N-1])*step
ans%=semi
print(ans)
