import math
n=int(input())
x=list(map(int,input().split()))
ans=0
a=[]
ans=0
for i in range(n-1):
  a.append(x[i+1]-x[i])
ans+=math.factorial(n-1)*sum(a)
for i in range(1,n):
  ans+=math.factorial(i)*sum(a[i:len(a)])
print(ans*math.factorial(n-1))
  