n = int(input())
x = list(map(int, input().split()))
ans = 0
pattern = 1
for i in range(1, n):
  pattern *= i
p=1
k=pattern
while p < n:
  ans += k * (x[p]-x[p-1])
  ans %= 1000000007
  p += 1
  k += pattern//(p)
print(ans)