MOD = 10 ** 9 + 7
n = int(input())
x = list(map(int, input().split()))
f = 1
for i in range(n - 1):
    f *= (i + 1)
    f %= MOD
ans = 0
t = 0
for i in range(n - 1):
    t += f // (i + 1)
    ans += t * (x[i + 1] - x[i])
print(ans % MOD)
