import math

n=int(input())
x = list(map(int, input().split()))
ans=0
mod=10**9+7


for i in range(1,n):
    print(x[n-1],x[i])
    ans+=(x[n-1]-x[i-1])/i
    ans%=mod

ans*=math.factorial(n-1)
ans%=mod

print(int(ans))