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 * (a[N-1] - a[i]) // ( i+1 )
    result = result%M

print( result )