N, *X = map(int, open(0).read().split())

D = [X[i + 1] - X[i] for i in range(N - 1)]
S = [0] * N
for i in range(N - 1):
    S[i + 1] = S[i] + D[N - i - 2]
S = S[::-1]

MOD = 10 ** 9 + 7
ans = [0] * (N - 1)
for c, i in enumerate(reversed(range(N - 1))):
    for j in range(i + 1, N):
        ans[c] += S[i] - S[j]

for i in range(N - 1):
    for j in range(N - 1):
        if i == j:
            continue
        ans[i] *= (j + 1)

print(sum(ans) % MOD)
