n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
fra=[1]*(n-1)
for i in range(1,n-1):
    fra[i]=(i+1)*fra[i-1]%mod
fra2=[1]*n
for i in range(1,n):
    fra2[i]=i*fra2[i-1]%mod
ans=0
edge=[0]*n
for i in range(n-2,-1,-1):
    k=n-1-i
    for j in range(i+1,n):
        edge[j]=(edge[j]+fra2[n-i-2]*k*(fra[n-2]//fra[n-i-2]))%mod
        k-=1
for i in range(1,n):
    ans=(ans+edge[i]*(a[i]-a[i-1]))%mod
print(ans)