N=int(input())
X=list(map(int,input().split()))
MOD=10**9+7

facN_1=1
for i in range(2,N):
    facN_1*=i

P=[0]*N
for i in range(1,N):
    P[i]=facN_1//i

ans=0
for i in range(N-1):
    tmp=X[i+1]-X[i]
    tmp*=(i+1)*(i+2)//2
    tmp*=P[i+1]%MOD
    ans+=tmp
    ans%=MOD
print(ans)