MOD = 10**9+7         # 問題に合わせて適宜書き換え
list_size = 252525    # 問題に合わせて適宜書き換え

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = ((f_list[i] * (i+2)) % MOD)

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(-2, -list_size-1, -1):
	f_r_list[i] = ((f_r_list[i+1] * (list_size + 2 + i)) % MOD)

N = int(input())
if N > 2525:
    print(-1)
    exit()
X = list(map(int,input().split()))
# print(f_list[N-1],f_r_list[N-1],(f_list[N-1]*f_r_list[N-1])%MOD)
ans = 0
for i in range(N):
    hoge = f_list[N-2]
    for j in range(i+1,N-1):
        piyo= (hoge*pow(j-i+1,MOD-2,MOD))%MOD
        hoge -= piyo
        ans += (X[j]-X[i])*piyo

        ans %= MOD
    ans += (X[-1]-X[i])*hoge
    ans %= MOD
print(ans)

