import math
import numpy as np

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

# 最低移動和?
move_min = x[len(x)-1] - x[0]
print("min:", x[len(x)-1] - x[0])
# 最大値計算?
move_max = np.sum(np.abs(x - x[-1]))
print(np.abs(x - x[-1]))
print("max:", np.sum(np.abs(x - x[-1])))
# 平均期待値?
hope = (move_max + move_min) / 2
print(np.longlong(hope * math.factorial(n - 1) % 1000000007))
