import math
n = int(input())
x = list(map(int, input().split()))
r = 10 ** 9 + 7
if n <= 2000:
    p = math.factorial(n - 1)
    ans = 0
    f = x[n - 1]
    for i in range(n-1):
        ans += (f - x[i]) * p
        ans %= r
        p = p * (i + 1) // (i + 2)

else:
    p = 1
    for i in range(1,n):
        p *= i
        p %= r
    ans = 0
    f = x[n - 1]
    for i in range(n-1):
        ans += (f - x[i]) * p
        ans %= r
        p = p * (i + 1) // (i + 2)
    
print(ans)