import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
res = 0
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)
for i in range(N - 1):
  for j in range(i, N - 1):
    res += f.factorial(j - i) * f.combi(N - 1, j - i + (j == N - 2)) % mod * (a[j + 1] - a[i]) % mod
    res %= mod
    #print(i, j, res, f.factorial(j - i) * f.combi(N - 1, j - i + (j == N - 1)), (a[j + 1] - a[i]))
print(res)