def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
def factorial_cor(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n=int(input())
x=list(map(int,input().split()))
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    if j!=n-1:
      ans+=((x[j]-x[i]))*(cmb(n-1,j-i+1,mod)*factorial_cor(n-1-j+i-1)%mod*factorial_cor(j-i-1)%mod)
    else:
      ans+=((x[j]-x[i]))*(cmb(n-1,j-i,mod)*factorial_cor(n-1-j+i)%mod*factorial_cor(j-i-1)%mod)
print(ans%mod)