import math
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

n = int(input())
slime = [int(x) for x in input().split()]
md = 10**9+7
fct = math.factorial(n-1) % md
aa = 0
for i in range(n-1):
    for j in range(i+1,n):
        buf_c = j - i - 1
        buf_p = j - i + 1
        if j == n - 1:
            buf_p -= 1
        if buf_c == 0:
            buf_c = 1
        buf_sum = fct * math.factorial(buf_c) % md
        buf_sum = buf_sum * mod_inv(math.factorial(buf_p), md)
        aa += (buf_sum * (slime[j] - slime[i])) % md
        aa %= md
print(int(aa))