mod = 10**9+7
N = int(input())
x = list(map(int,input().split()))

l = [0]*(N-1)
for i in range(0,N-1):
    l[i] = x[i+1]-x[i]

print(l)
total = 0

for i in range(0,N-1):
    poyo = 1
    for j in range(0,N-1):
        if i != j:
            poyo = poyo * (j+1) % mod
        
    total = (total + poyo*l[i]*(2*(i+1)-1)) % mod
 
print(total)

