import math

N = int(input())
X = list(map(int, input().split()))
x_max = X[N-1]

d_max = 0
for x in reversed(X):
	d_max += (x_max - x)
	
d_min = 0
prev = X[0]
for x in X:
	d_min += (x - prev)
	prev = x

ev = (d_max+d_min)/2

#print(X)
#print(d_min, d_max)
#print(math.factorial(N-1), ev)
print(int(math.factorial(N-1)*ev % (10**9+7)))