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

mod = 10 ** 9 + 7
f = [1]
for i in range(1,N+1):
    f.append((f[-1] * i) % mod)
def comb(n,r):
    return f[n] * (pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod) % mod

ans = 0
l = [0] + [(((comb(N-1,2+i) * f[N-(3+i)]) % mod) * f[i]) % mod for i in range(N-2)] + [f[N-2]]


for i in range(N-1):
    for j in range(i+1,N):
        ans += (l[j-i] * (x[j] - x[i])) % mod
        ans %= mod
        if j == N - 1:
            l[j-i-1] = l[j-i-1] + l[j-i]

print(ans)