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

ans = 0

cnt = 1
for i in range(1, n):
    cnt = cnt*i % (10**9+7)

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

print(ans)
