# -*- coding: utf-8 -*-
import sys

N=input()
X=map(int, sys.stdin.readline().split())

mod=10**9+7
fact, inv_fact = [1], [1]
fact_tmp = 1
for i in range(1, N+1):
    fact_tmp *= i
    fact_tmp %= mod
    fact.append(fact_tmp)
    inv_fact.append(pow(fact_tmp, mod-2, mod))
 
 
def ncr(n,r):
	if n < 0 or r < 0 or n < r:	return 0
	else:	return (fact[n] * inv_fact[r] * inv_fact[n-r]) %mod

ans=0
for i in range(N):
    for j in range(i+1,N):
        l=j-i+1   #配列の長さ
        if j==N-1: l-=1
        #print "i,j,l,X[i],X[j] :: ",i,j,l,X[i],X[j]
        #print "(X[j]-X[i]),ncr(N-1,l),(X[j]-X[i])*ncr(N-1,l) :: ",(X[j]-X[i]),ncr(N-1,l),(X[j]-X[i])*ncr(N-1,l)
        ans+=(X[j]-X[i])*ncr(N-1,l)

print ans%mod
