mod = 10**9+7
n = int(input())
x = [int(x) for x in input().split()]
x = x[::-1]

dp = [0 for _ in range(n)]
dp[0] = 0

dp[1] = x[0]-x[1]

xx = [0]
for i in range(n):
    xx.append((xx[-1]+x[i]) % mod)

fact = [1]
for i in range(n+1):
    fact.append((fact[-1]*(i+1)) % mod)

for i in range(2, n):
    dp[i] += i*dp[i-1] + (x[0]-x[i])*fact[i-1]
    for k in range(1, i):
        dp[i] += (x[k]-x[i]) * fact[i] // (fact[i-k+1]//fact[i-k-1])
    dp[i] %= mod

print(dp[n-1])
