import sys
sys.setrecursionlimit(10**6)
N=int(input())
X=list(map(int,input().split()))
A=[]
for i in range(1,N):
  A.append(X[i]-X[i-1])
  
MOD=10**9+7

def kaijyo(n):
	if n ==0 or n == 1:
		return 1
	else:
		return ((n%MOD)*(kaijyo(n-1)%MOD))%MOD

sumtmp=0
for i in range(len(A)):
  sumtmp+=((i+2)*A[i])%MOD
print(int(sumtmp*kaijyo(N-1)/2)%MOD)