from statistics import mean
from math import factorial
import numpy as np
N = int(input())
H = list(map(int, input().split()))
MOD = 1000000007
diff=[]
for i in range(N-1):
    diff.append(H[i+1]-H[i])

diff=np.array(diff)
multi=np.array([mean(list(range(1,i+1)))*factorial(N-1) for i in range(1,N)])
# print(multi)
# print(diff)
print(int(np.sum(diff*multi)%MOD))