import math
n = int(input())
x = list(map(int,input().split()))

move = 0


for i in range(n-1):
    ls = x.copy()
    move += abs(ls[i]-ls[i+1])
    ls.remove(ls[i])
    for j in range(n-2):
        move += abs(ls[j+1]-ls[j])
        
ans = move*(1/(n-1))
print(round((math.factorial(n-1)*ans)%(10**9+7)))

    
