import numpy as np


def cumprod(arr, MOD):
    L = len(arr)
    Lsq = int(L**.5 + 1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n - 1]
        arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n - 1, -1]
        arr[n] %= MOD
    return arr.ravel()[:L]


def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64)
    x[0] = pow(int(fact[-1]), MOD - 2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv


N = int(input())
x = np.array(list(map(int, input().split())))

mod = 10**9 + 7

v_dic = {}

for i in range(N - 1):
    d = x[-1] - x[i]
    v_dic[(x[i], x[-1])] = d


def f(arr):
    t = tuple(arr)
    if v_dic.get(t):
        return v_dic.get(t)
    s = 0
    for i in np.arange(arr.shape[0] - 1):
        _arr = arr[np.arange(arr.shape[0]) != i]
        v = arr[i + 1] - arr[i]
        s += v % mod
        s += f(_arr) % mod
    v_dic[t] = s % mod
    return s


s = f(x)
print(s % mod)
