import math
mod = 10**9 + 7
n = int(input())
lst = list(map(int, input().split()))
sp = [lst[i+1]-lst[i] for i in range(n-1)]
lensp = n-1

min_ = sum(sp)
max_ = 0
t = 0
for l in sp[::-1]:
    t += l
    max_ += t
exp = (min_+max_)/2
ans = (exp*math.factorial(n-1)) % mod
print(ans)