N=int(input())
x = list(map(int,input().split()))
dp = [[0]*(N+2) for _ in range(2)]
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+1)%2+1
    i3 = i%2+1
    for j in range(1,i+2):
        if i+1==j:
            dp[i3][j] = (dp[i2][j-1]*(i-0) + a)%MOD
        elif j==1:
            dp[i3][j] = (dp[i2][j]*(i-1) - a)%MOD
        else:
            dp[i3][j] = (dp[i2][j]*(i-j) + dp[i2][j-1] * (j-1))%MOD
res = 0
n = (N-1)%2
for i in range(N):
    res += (dp[n][i+1]*x[i])%MOD
print(res%MOD)
