# -*- coding: utf-8 -*-

import math
mod = 10**9 +7
N = int(input())
X = list(map(int, input().split()))

ans=0
for i in range(1,N):
    ans = (ans*i + (X[-1]-X[i-1])*math.factorial(i-1)) %mod

print(ans)