import numpy as np
n = int(input())
x = input().split(" ")
x = np.array(list(map(int, x)))
print(x)
num = 1
ans = 0
minus = 0
for i in range(n-1):
    num *= n-(i+1)
    minus += x[i]
    ans += ((i+1) * x[-1] - minus) / (num)
print((ans*num) % (10**9 + 7))