import math

dev = 10**9+7

def kai(n):
    if n == 1:
        return 1
    else:
        return (n * kai(n-1))


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

s = 0
now = 0
#f = kai(N-1) % dev
f = math.factorial(N-1)
for i in range(N-1):
  now += (f/(i+1)) % dev
  s += (((X[i+1]-X[i])%dev)*now) % dev

print(int(s%dev))

