def read():
    N = int(input().strip())
    X = list(map(int, input().strip().split()))
    return N, X

def solve(N, X, MOD=1000000007):
    rank = [0 for j in range(N+1)]
    rank[0] = 1
    rank[1] = 1
    for i in range(2, N+1):
        rank[i] = (rank[i-1] * i) % MOD

    cost = [[0 for j in range(N+1)] for i in range(N+1)]

    # cost[i][j] := 区間[i, j) のスライムを結合するコスト
    for i in range(N-1):
        cost[i][i+2] = X[i+1] - X[i]
    
    for i in reversed(range(0, N)):
        for j in reversed(range(i+1, N+1)):
            for k in range(i+1, j-1):
                cost[i][j] += cost[i][k] + cost[k][j] + (X[j-1]- X[k-1]) * rank[k-i] * rank[j-k]
                cost[i][j] %= MOD

    return cost[0][N]

if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))
