from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

# In[]:
N = inp()
xx = inpl()

# N = 3
# xx = 1,2,3

# In[]:
aa = [1]
fac = 1
for L in range(2,N):
    fac *= L-1
    naa = [fac]*L
    for i in range(L):
        if i < L-1:
            naa[i] += (L-i-1)*aa[i]
        if 1 <= i:
            naa[i] += (i+1)*aa[i-1]
        naa[i] %= mod

    aa = naa[:]
    # print(aa)

# print(aa)

# In[]:
dx = [xx[i]-xx[i-1] for i in range(1,N)]
# print(dx)

# In[]:
ans = 0
# print(aa)
# print(dx)
for a,d in zip(aa,dx):
    ans += a*d

print(ans%mod)
