n=int(input())
x=list(map(int, input().split()))
y=[x[i+1]-x[i] for i in range(n-1)]
mod=10**9+7

def suraimu(n):
    dp=[[] for i in range(n)]
    dp[1].append(1)
    if n>2:
        for i in range(1,n-1):
            dp[i+1]=[(i+1)*j%mod for j in dp[i]]+[(dp[i][-1]*(i+1)+dp[i][0])%mod]
    return dp

z=suraimu(n)[-1]

ans=sum([z[i]*y[i] for i in range(n-1)])%mod
print(ans)