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

modn = 1
for i in range(1,n):
    modn *= i
    modn %= mod

ans = 0

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