N = int(input())
X = list(map(int,input().split()))
import numpy as np
import math
ans = 0
mod = 10**9+7
x=X[-1]
for i in range(N-1):
  for j in range(i+1,N-1):
    a = j-i-1
    ans += ((X[j]-X[i])%mod)*(math.factorial(a)%mod)*(math.factorial(N-1)%mod*pow(math.factorial(a+2),mod-2,mod))%mod
    
for k,y in enumerate(X[:N-1:]):
  a = N-k-2
  ans+=((x-y)%mod)*(math.factorial(a)%mod)*(math.factorial(N-1)%mod*pow(math.factorial(a+1),mod-2,mod))%mod
print(ans%mod)
