n = int(input())
x = list(map(int, input().split()))
r = 10 ** 9 + 7
a = [1]
p = 1
for i in range(1, n - 1):
    p *= i
    q = p + a[0] * (i + 1)
    a = [q] + a

ans = (x[n - 1] - x[n - 2]) * a[0]
ans %= r
k = n - 1
for i in range(2, n):
    ans += (x[n - i] - x[n - i - 1]) * a[i - 1] * k
    ans %= r
    k *= n - i

print(ans)