import sys
input = sys.stdin.readline
N = int(input())
x = list(map(int, input().split()))
mod = 10 ** 9 + 7

class Factorial:
  def __init__(self, n, mod):
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod

f = Factorial(N, mod)
dp = [0] * N
res = 0
for i in range(N - 2):
  for j in range(i + 1, N):
    t = f.combi(N - 1, min(j - i + 1 - (j == N - 1), N - 1)) * f.factorial(j - i - 1) % mod
    #print(i, j, t)
    #t *= f.factorial(N - 1) * f.ifactorial(t) % mod
    #print(i, j, t)
    dp[i] += t * (x[j] - x[i])
    dp[i] %= mod
dp[N - 2] = f.factorial(N - 1) * (x[-1] - x[-2]) % mod
for i in range(N):
  res += dp[i]
  res %= mod
print(res)