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)
for i in range(N-1):
  n = 0
  for j in range(i+1):
    n = n + (fact / (j+1))
  ans = ans + diff[i] * n

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