import math

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

ans = 0

for i in range(n - 1):
    for j in range(i):
        k = i - j
        ans += (ls[i] - ls[j]) / (k * (k + 1)) 
        
for l in range(n - 1):
    k = n - 1 - l
    ans += (ls[n - 1] - ls[l]) / k

print(int((ans * math.factorial(n - 1)) % (10 ** 9 + 7)))