n=int(input())
a=list(map(int,input().split()))
b=[0]
for i in range(n-1):b.append(b[-1]+a[i+1]-a[i])
mod=10**9+7
ans=0
c=[]
for i in range(n-1):
  c.append(1)
  for j in range(len(c)):
    c[j]*=n-1-i
    c[j]%=mod
for i in range(n-1):
  m=c[-1-i]
  for j in range(i,n-1):
    ans+=m*(b[j+1]-b[i])
    ans%=mod
print(ans)