import sys
def input():
    return sys.stdin.readline()[:-1]
pr=10**9+7
N=int(input())
x = tuple(map(int, input().split()))
s=1
for i in range(2,N):
    s=s*i%pr
l=[None]*(N-1)
t=s
for i in range(N-1):
    l[i]=t
    s=s*(i+1)//(i+2)%pr
    t=(t+s)%pr
a=0
for i in range(N-1):
    a+=(x[i+1]-x[i])*l[i]%pr
print(a%pr)