import copy
import numpy as np
import fractions
import itertools

n = int(input())

l = input().split()

for i in range(n):
    l[i] = int(l[i])

new_l = [l[n-1]-i for i in l]
# print(new_l)

new_l.pop()
new_l.reverse()

length = len(new_l)
allSum = 0

for i in range(length):
    ruiseki = np.cumsum(new_l)
    allSum += sum(ruiseki)
    new_l.pop()

ruiseki = np.cumsum(new_l)
allSum += sum(ruiseki)
# print(ruiseki)
print(allSum)
# ans = allSum/fractions.factorial(n)
factorial = 1
# print(len(list(itertools.permutations(new_l))))
for i in range(1, n):
    factorial *= i
print(factorial)

ans = int(allSum/(n-1) * factorial)
print(ans)
print(ans % 1000000007)
