#----------------------------------------------------------
P = 10**9 + 7
N = 100001 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心
inv = [0] + [1] # 1/x
finv = [1] + [1] # 1/x!
fac = [1] + [1] # x!
for i in range(2,N):
  inv += [inv[P % i] * (P - int(P / i)) % P]
  fac += [(fac[i-1] * i) % P]
  finv += [(finv[i-1] * inv[i]) % P]

def comb(a, b):
    if a<b or a<0 or b<0:
        return 0 # error
    return (fac[a] * ((finv[b] * finv[a-b]) % P)) %P
#----------------------------------------------------------

n=int(input())
x=list(map(int,input().split()))
ans=0
for i in range(n-1):
    t = (x[n-1]-x[i])%P
    o =(fac[i]*fac[n-2-i])%P
    g = (comb(n-1,n-1-i)*o)%P
    t = (t * g)%P
    ans=(ans+t)%P

for i in range(n-1):
    for j in range(i+1,n-1):
        t = (x[j]-x[i])%P
        o =(fac[n-1-j+i-1]*fac[j-i-1])%P
        g = (comb(n-1,j-i+1)*o)%P
        t = (t * g)%P
        ans=(ans + t)%P
print(ans%P)
