n = int(input())
X = list(map(int, input().split()))

ans = 0
multi = 1
for i in range(1,n):
    multi *= i

n_two = 1
for j in range(1,n-1):
    n_two *= j


for i in range(n-1):
    base = (X[i+1] - X[i])*multi + (X[i+1]-X[i])*(2*i*n_two/2)
    ans += int(base)
    ans = ans % (10**9+7)

ans = ans % (10** 9 + 7)
print(ans)