def modinv2(a,m):
    return pow(a,m-2,m)

def f(n,m):
    a = 1
    for i in range(2,n+1):
        a = a*i%m
    return a

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

ans = 0
P = 10**9+7

b = f(N-1,P)

for i in range(N-1):
    l = x[i+1]-x[i]
    for j in range(i+1):
        c = modinv2(j+1,P)
        ans += (l*c%P)*b%P

print(ans%P)
