n = int(input())
x = list(map(int, input().split()))
def fact(a):
    if a == 1:
        return 1
    else: return a * fact(a-1)
def xx(a):
    if a == 1:
        return [1]
    else: 
        b = xx(a-1)
        for i in range(a-1):
            b[i] *= a
        b.append(b[a-2] + fact(a-1))
        return b
y = xx(n-1)
ans = 0
for i in range(n-1):
    ans += y[i] * (x[i+1]-x[i])
print(ans%1000000007)