import math

dev = 10**9+7

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

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

print(int(s%dev))

