mod = 10**9 + 7
n = int(input())
l = list(map(int, input().split()))
 
d, ans = 0, 0
 
for i in range(1, n):
  f = 1 if i == 1 else f * (i-1) % mod
  d = (d * i + f) % mod
  ans = (ans * i + (l[i] - l[i-1]) * d) % mod
 
print(ans)