from math import factorial

N = int(input())
x_list = list(map(str, input().split()))
for i in range(N):
    x_list[i] = int(x_list[i])

result = 0
for i in range(N-1):
    keisu = factorial(N-2-i)*factorial(i)
    for j in range(N-1-i):
        result += keisu*(x_list[N-1] - x_list[j])*(int(factorial(N-2-j) / factorial(i) / factorial(N-2-j - i)))
        result %= (1000000000+7)
print(result)