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

mod = 10**9 + 7

l = []
for i in range(n-1):
    d = x[i+1] - x[i]
    l.append(d)

# print(l)

import math
f = math.factorial(n-1)

count = 0

for i in range(1,n):
    k = f * 1/i * (n-i) 
    plus = l[i-1] * k
    count += plus

print(int(count)%mod)