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