def factorial_cor(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact
n = int(input())
X = list(map(int, input().split()))
sub = []
for i in range(1, n):
  sub.append(X[i]-X[i-1])
times = [factorial_cor(n-1)]
for i in range(2, n):
  a = 0
  for j in range(n-i):
    a += factorial_cor(j)
  times.append(times[i-2]+a)
ans = 0
ans = sum(sub[k]*times[k]%(1000000007) for k in range(n-1))
print(ans)