p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p

N = int(input())
A = [1 for _ in range(N+1)]
for i in range(2,N+1):
    A[i] = (A[i-1]*i)%p
B = [1 for _ in range(N+1)]
B[N] = pow(A[N],p-2)
for i in range(N-1,1,-1):
    B[i] = (B[i+1]*(i+1))%p
X = list(map(int,input().split()))
X.insert(0,0)
C = [0 for i in range(N+1)]
C[1] = A[N-1]
for i in range(2,N):
    C[i] = (C[i-1]-A[N-1]*B[i])%p
C[N] = 0
for i in range(1,N):
    C[N] = (C[N]+C[i])%p
ans = (C[N]*X[N])%p
for i in range(1,N):
    ans = (ans-C[i]*X[i])%p
print(ans)