import math
import itertools
import copy

N = int(input())
x = list(map(int, input().split()))
n = []
d = []

exp_len = 0

for i in range(N):
  n.append(i)

for i in range(N-1):
  d.append(x[i+1] - x[i])

n_list = list(itertools.permutations(n[:-1]))

for i in range(math.factorial(N-1)):
  distance = copy.copy(d)
  for j in range(N - 1):
    if n_list[i][j] != 0:
      distance[n_list[i][j] - 1] += distance[n_list[i][j]]
    exp_len += distance[n_list[i][j]]

print(exp_len % 1000000007)