import sys
input = sys.stdin.readline

def inv(x):
    return pow(x, MOD-2, MOD)
    
def C(n, r):
    return fact[n]*inv(fact[r])*inv(fact[n-r])

N = int(input())

if N>3000:
    1/0
    
x = list(map(int, input().split()))
ans = 0
MOD = 10**9+7
fact = [1]

for i in range(1, N):
    fact.append(fact[-1]*i%MOD)
    
for i in range(N-1):
    for j in range(i+1, N):
        #print(i, j)
        
        #r = j-i+1
        add = 1
        
        if j==N-1:
            r = N-2-i+1
            add *= (x[j]-x[i])
            add %= MOD
            add *= C(N-1, r)
            add %= MOD
            add *= fact[r-1]
            add %= MOD
            add *= fact[N-1-r]
            add %= MOD
            #ans += (x[j]-x[i])*C(N-1, r)*fact[r-1]*fact[N-1-r]
            ans += add
            #print(C(N-1, r-1)*fact[N-1-r+1]*fact[r-2])
        else:
            r = j-i+1
            add *= (x[j]-x[i])
            add %= MOD
            add *= C(N-1, r)
            add %= MOD
            add *= fact[j-i-1]
            add %= MOD
            add *= fact[N-1-r]
            add %= MOD
            ans += add
            #ans += (x[j]-x[i])*C(N-1, r)*fact[j-i-1]*fact[N-1-r]
        #print(x[j]-x[i])
            #print(C(N-1, r)*fact[N-1-r]*fact[r-2])
        #ans += (x[j]-x[i])*C(N-1, r)*fact[N-1-r]
        #print('ans:', ans)
        ans %= MOD

#ans *= fact[N-1]
ans %= MOD

print(ans)