# coding: utf-8
# Your code here!

N=int(input())
X=list(map(int,input().split()))
MOD=10**9+7

D=[]

for i in range(N-1):
    D.append(X[i+1]-X[i])

pn=[1]

for i in range(N):
    pn.append(pn[i]*(i+1))


ans=0
for i in range(N-1):
    ans+=(pn[N-1]*(i+1)-pn[N-3]*i*(N-3)*(N-2)//2)*D[i]%MOD

print(ans)
print(pn)
