N=int(input())
X=list(map(int,input().split()))
a=1
b=1
c=10**9+7
for i in range(N)[1:]:
    a=a*i
for i in range(N-1):
    b*=i+1
l1=list()
l2=list()
ans=0
for i in range(N):
    A=a
    for j in range(N-i-2):
        l1.append(a/((j+2)*(j+1)))
        A=A-a/((j+2)*(j+1))
    l1.append(A)
l1.pop(-1)
for i in range(N):
    for j in range(N)[i+1:]:
        l2.append(X[j]-X[i])
for n1,n2 in zip(l1,l2):
    ans+=n1*n2
print(int(ans%c))