n = int(input())
st = list(map(int, input().split()))

MOD = 10 ** 9 + 7

dif = [j - i for i, j in zip(st, st[1:])]

li = []
ho = 0
for i in range(1, n):
  d = 1
  for j in range(1, n):
    if j != i:
      d = (d * j) % MOD  
  ho += d
  li.append(ho)

ans = 0
for i, j in zip(dif, li):
  ans = (ans + (i % MOD) * (j % MOD)) % MOD 

print(ans % MOD)