N = int(input())
X = list(map(int, input().split()))
sosu = 10 ** 9 + 7

fac = [1 for i in range(N)]
inv = [0 for i in range(N)]
for i in range(1, N):
    fac[i] = fac[i-1] * i % sosu
    inv[i] = pow(i, sosu-2, sosu)
#Sprint(fac)
ans = 0
for i in range(N):
    for j in range(i+1, N):
        kyori = X[j] - X[i]
        #print(kyori)
        if j == N-1:
            kaisu = fac[N-1] * inv[j-i] % sosu
            #(N-1)! / (j-i)#= (j-i-1)! * ((j-i-1)+ 1 + 1) * .. * (N-1)
        else:
            kaisu = (fac[N-1] * inv[j-i] % sosu) * inv[j-i+1] % sosu
            #(N-1)! / (j-i)(j-i+1) #(j-i-1)! * ((j-i-1) +2+1) * ... * (N-1)
        #print(kaisu)
        ans += kyori * kaisu % sosu
        ans = ans % sosu
print(ans)



'''
ma = X[N-1] - X[0]
S = [0 for i in range(N-1)]
for i in range(N-1):
    S[i] = X[i+1] - X[i]
kaijo = [1 for i in range(N)]
for i in range(1, N):
    kaijo[i] = kaijo[i-1] * i % sosu

print(S)
'''