import math

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

diff = []

#for i in range(N-1):
#  d = x[i+1] - x[i]
#  diff.append(d)
  
ans = 0
fact = math.factorial(N-1)
n = 0
for i in range(N-1):
  d = x[i+1] - x[i]
  #diff.append(d)
  n = n + (fact // (i+1))
  ans = ans + d * n

mod = ans % (10**9 + 7)
print(int(mod))