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

i=N-1
a=1
while i!=0:
  a*=i
  a%=mod
  i-=1
b=0
ans=0
for i in range(N-1):
  b+=a/(i+1)
  b%=mod
  ans+=b*(X[i+1]-X[i])
  ans%=mod
  
print(int(ans))