import math
N = int(input())
x = [int(_) for _ in input().split()]
wari = 10 ** 9 + 7
X = 2 ** (N - 2)
xMax = max(x)
w = 0

for i in range(N - 1):
    val = xMax - x[i]
    if i == 0:
        w += val * X
    else:
        w += val * (X // 2)

left = (w / X)
right = math.factorial(N - 1)
ans = int(left * right)
print(ans % wari)