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

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

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

t += l * F

for i in range(0, N-1):
    x = X[i+1] - X[i]
    t += x * F * i

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