import numpy as np

MOD = 10 ** 9 + 7
N = int(input())
x = list(map(int, input().split()))
x.sort()
x_arr = np.array(x)
x_diff = np.diff(x_arr)

a = np.zeros(N - 1, dtype=int)
a[0] += 1
for i in range(1, N - 1):
    a[i] = a[0]
    a[:i] = a[:i] * (i + 1) % MOD
a = np.cumsum(a) % MOD

print(np.dot(a, x_diff) % MOD)
