N = int(input())
a = list( map(int, input().split() ) )
kai = 1
M = 10**9+7
result = 0
for i in range(1,N):
    kai *= i

for i in range(N-1):
    result += ((kai//(i+1))%M) * (a[N-1] - a[i])

print( result%M )