import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappop, heappush
import math

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(input())
X = list(map(int, input().split()))

F = 1
l = X[N-1] - X[0]
t = 0
N_1 = math.factorial(N-1)

for i in range(1, N-1):
    F *= i
    N_1 //= N-i
    t += l * F * N_1

s = sum(X)

t = t + s - X[0] - (X[0] * (N-1))

print(t % ((10**9)+7))
