N = int(input())
X = [int(x) for x in input().split()]

C = 1000000007

dp = []
for i in range(N + 1):
    dp.append([0] * (i + 3))
dp[0][1] = 1
for i in range(1, N + 1):
    for j in range(1, i + 2):
        dp[i][j] = dp[i-1][j-1] + dp[i-1][j] * i

dis = []
for i in range(N):
    dis.append(X[i + 1] - X[i])

ans = 0
for i in range(N):
    for j in range(i + 3):
        for k in range(N - i):
            dp[i][j] *= k
            dp[i][j] %= C
            dp[i][j] *= j
            dp[i][j] %= C
            dp[i][j] *= dis[i]
            ans += dp[i][j]
            ans %= C

print(ans)