N = int(input())
x = list(map(int,input().split()))
dp = [[0]*(N+2) for _ in range(3)]
dp[1][0] = -1
dp[1][1] = -1
dp[1][2] = 1
a = 1
MOD = 10**9+7
for i in range(2,N):
    a = (a*(i-1))%MOD
    i2 = (i+2)%2+1
    i3 = (i+1)%2+1
    dp[i3][1] = (dp[i2][1]*(i-1) - a)%MOD
    for j in range(1,i+2):
        dp[i3][j] = (dp[i2][j]*(i-j) + dp[i2][j-1] * (j-1))%MOD
    dp[i3][i+1] = (dp[i2][i]*i + a)%MOD
res = 0
n = (N-2)%2+1
for i in range(N):
    res += (dp[n][i+1]*x[i])%MOD
print(res%MOD)
