import sys
n=int(input())
x=list(map(int,input().split()))
if n>2000:
  sys.exit()
mod=10**9+7
l=[]
l2=[1 for i in range(n-1)]
for i in range(n-1):
  l.append(x[i+1]-x[i])
for i in range(1,n):
  for j in range(n-1):
    if i!=j+1:
      l2[j]*=i
      l2[j]%=mod
l3=[]
l3.append(l2[0])
for i in range(n-2):
  l3.append(l3[-1]+l2[i+1])
ans=0
for i in range(n-1):
  ans+=l3[i]*l[i]
  ans%=mod
print(ans)