n = int(input())
X = list(map(int, input().split()))

ans = 0

cnt = 1
for i in range(1, n):
    cnt = cnt*i

excnt = [0, 0]
for i in range(2, n):
    ex = cnt // i
    excnt.append(excnt[-1]+ex)


for i in range(1, n):
    l = X[i] - X[i-1]
    ans += l * (cnt + excnt[i])
    ans = ans % (10**9+7)

print(ans)
