n = int(input())
x = list(map(int, input().split()))
def fact(a):
    if a == 1:
        return 1
    else: 
        b = 1
        for i in range(1,a+1):
            b *= i
    return b
def xx(a):
    if a == 1:
        return [1] 
    else:
        b = [1]
        for i in range(2, a+1):
            for j in range(len(b)):
                b[j] *= i
            b.append(b[len(b)-1] + fact(i-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)