MOD = 10**9+7

N = int(input())
x = list(map(int, input().split()))

f = [1]
for i in range(N):
    f.append(f[-1]*(i+1)%MOD)

ans = 0
c = 0
for i in range(N-1):
    if f[N-1] % (i+1):
        c += f[N-1]
    else:
        c += f[N-1] // (i+1)
    ans += c * (x[i+1] - x[i])
    ans %= MOD
print(ans)