N = int(input())
x = list(map(int,input().split()))

k = N - 1

MoveDist = 0

def Dist(count, DistSum = 0):
  for i in reversed(range(count)):
    DistSum = x[count] - x[count - 1]
    DistSum *= K - count
  
MoveDist = Dist(k)