Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number b_{i}. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference is maximal possible!

Your task is to write a program which calculates two things:  The maximum beauty difference of flowers that Pashmak can give to Parmida.  The number of ways that Pashmak can pick the flowers. Two ways are considered different if and only if there is at least one flower that is chosen in the first way and not chosen in the second way. 


-----Input-----

The first line of the input contains n (2 ≤ n ≤ 2·10^5). In the next line there are n space-separated integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 10^9).


-----Output-----

The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively.


-----Examples-----
Input
2
1 2

Output
1 1
Input
3
1 4 5

Output
4 1
Input
5
3 1 2 3 1

Output
2 4


-----Note-----

In the third sample the maximum beauty difference is 2 and there are 4 ways to do this:  choosing the first and the second flowers;  choosing the first and the fifth flowers;  choosing the fourth and the second flowers;  choosing the fourth and the fifth flowers.

Source: codeforces | Difficulty: EASY
Tags: Sorting

Combinatorics

Implementation


Solutions:
n = int(input())
f = list(map(int, input().split(' ')))
(f, m, M) = (sorted(f), min(f), max(f))
print(M - m, end=' ')
if m != M:
	print(f.count(m) * f.count(M))
else:
	print(f.count(m) * (f.count(m) - 1) // 2)


import sys
n = int(sys.stdin.readline())
b = [int(x) for x in sys.stdin.readline().split()]
b.sort()
if b[0] == b[-1]:
	print(0, n * (n - 1) // 2)
else:
	d = b[-1] - b[0]
	i = 0
	while b[i] == b[i + 1]:
		i += 1
	j = n - 1
	while b[j] == b[j - 1]:
		j -= 1
	print(d, (i + 1) * (n - j))


n = int(input())
x = list(map(int, input().split()))
a = max(x)
b = min(x)
ca = x.count(a)
cb = x.count(b)
if a == b:
	print(a - b, ca * (ca - 1) // 2)
else:
	print(a - b, ca * cb)


n = int(input())
ar = list(map(int, input().split()))
print(max(ar) - min(ar), ar.count(max(ar)) * ar.count(min(ar)) if max(ar) != min(ar) else ar.count(max(ar)) * (ar.count(max(ar)) - 1) // 2)


n = int(input())
f = list(map(int, input().split()))
d = max(f) - min(f)
t = 0
if d == 0:
	t += (len(f) - 1) * len(f) // 2
else:
	for x in range(min(f), max(f) - d + 1):
		t += f.count(x) * f.count(x + d)
print(d, t)


import math
n = int(input())
b = [int(x) for x in input().split()]
freq = {}
for i in range(0, n):
	freq[b[i]] = 0
for i in range(0, n):
	freq[b[i]] += 1
b.sort()
max_diff = b[-1] - b[0]
print(max_diff, end=' ')
count = 0
for i in range(0, n):
	other = max_diff + b[i]
	if other in freq:
		if other == b[i]:
			freq[other] -= 1
		count += freq[other]
print(count)


__author__ = 'curiousfool'
t = int(input())
n = list(map(int, input().split()))
n.sort()
maxdiff = n[len(n) - 1] - n[0]
ways = 0
m = x = 0
for i in range(0, len(n)):
	if n[i] == n[len(n) - 1]:
		m += 1
	if n[i] == n[0]:
		x += 1
if n[0] == n[len(n) - 1]:
	ways += int(t * (t - 1) / 2)
else:
	ways += max(m, x) * min(m, x)
print(maxdiff, ways)


a = int(input())
b = list(map(int, input().split()))
(x, y) = (min(b), max(b))
print(y - x, a * (a - 1) // 2 if x == y else b.count(x) * b.count(y))


import math
from itertools import combinations
n = int(input())
a = list(map(int, input().split()))
ma = max(a)
mi = min(a)
print(ma - mi, end=' ')
if ma - mi == 0:
	print(n * (n - 1) // 2)
else:
	print(a.count(ma) * a.count(mi))


import sys
import math
import collections

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	n = int(input())
	arr = get_list()
	arr.sort()
	diff = arr[-1] - arr[0]
	c_min = arr.count(arr[0])
	c_max = arr.count(arr[-1])
	c = c_max * c_min
	if diff > 0:
		print(diff, c)
	else:
		print(diff, c_min * (c_min - 1) // 2)


n = int(input())
flowers = [int(x) for x in input().split(' ')]
min_beauty = min(flowers)
max_beauty = max(flowers)
ans = max_beauty - min_beauty
n_min = flowers.count(min_beauty)
n_max = flowers.count(max_beauty)
if ans != 0:
	print(ans, n_min * n_max)
else:
	print(ans, int(n_min * (n_min - 1) / 2))


n = int(input())
s = [int(x) for x in input().split()]
s.sort()
diff = s[n - 1] - s[0]
total = 0
count_f = s.count(s[0])
count_l = s.count(s[n - 1])
total = count_f * count_l
if diff == 0:
	sop = n / 2 * (n - 1)
	print(0, int(sop))
else:
	print(diff, total)


n = int(input())
l = list(map(int, input().split()))
x = max(l)
y = min(l)
count1 = 0
count2 = 0
for i in range(n):
	if l[i] == x:
		count1 += 1
	if l[i] == y:
		count2 += 1
if x == y:
	print('0', n * (n - 1) // 2)
else:
	print(x - y, count1 * count2)


def Flowers(n, arr):
	M = max(arr)
	mi = min(arr)
	Mcount = 0
	micount = 0
	if M == mi:
		return (M - mi, n * (n - 1) // 2)
	for i in range(n):
		if arr[i] == M:
			Mcount += 1
		if arr[i] == mi:
			micount += 1
	return (M - mi, Mcount * micount)
n = int(input())
arr = list(map(int, input().split()))
for i in Flowers(n, arr):
	print(i, end=' ')


x = int(input())
(*li,) = map(int, input().split())
li.sort()
a = li.count(li[0])
b = li.count(li[-1])
if li[0] == li[-1]:
	ans = a * (a - 1) // 2
else:
	ans = a * b
print(li[-1] - li[0], ans)


n = int(input())
i = 0
mx = 1
mn = 1000000000
nmx = 0
nmn = 0
a = list(map(int, input().split()))
for i in range(n):
	if a[i] > mx:
		mx = a[i]
		nmx = 1
	elif a[i] == mx:
		nmx += 1
	if a[i] < mn:
		mn = a[i]
		nmn = 1
	elif a[i] == mn:
		nmn += 1
if mx == mn:
	print('0', str(n * (n - 1) // 2))
else:
	print(str(mx - mn), str(nmn * nmx))


n = int(input())
beauty = input().split()
beauty = [int(x) for x in beauty]
beauty.sort()
max_beauty = beauty[-1] - beauty[0]
if max_beauty == 0:
	count = n * (n - 1) // 2
else:
	base = beauty.count(beauty[0])
	end = beauty.count(beauty[-1])
	count = base * end
print(max_beauty, count)


n = int(input())
a = list(map(int, input().split()))
equal = True
for i in range(1, n):
	if a[i] != a[i - 1]:
		equal = False
		break
if equal:
	print('0 %d' % (n * (n - 1) / 2))
	exit(0)
a.sort()
(i, j) = (1, n - 2)
while a[i] == a[i - 1]:
	i = i + 1
while a[j] == a[j + 1]:
	j = j - 1
print('%d %d' % (a[n - 1] - a[0], i * (n - 1 - j)))


n = int(input())
a = [int(x) for x in input().split()]
k = max(a) - min(a)
if k == 0:
	print(k, n * (n - 1) // 2)
else:
	print(k, a.count(min(a)) * a.count(max(a)))


n = int(input())
li = list((int(i) for i in input().strip().split(' ')))
li.sort()
maxdif = li[-1] - li[0]
first = li.count(li[-1])
last = li.count(li[0])
print(maxdif, first * last) if maxdif != 0 else print(0, int(n * (n - 1) / 2))


n = int(input())
b = list(map(int, input().split()))
(max_b, min_b) = (max(b), min(b))
(max_count, min_count) = (b.count(max_b), b.count(min_b))
max_dif = max(b) - min(b)
if max_dif == 0:
	ways = max_count * (max_count - 1) // 2
else:
	ways = max_count * min_count
print(max_dif, ways)


n = int(input())
b = list(map(int, input().split()))
mx = max(b)
mn = min(b)
if mx == mn:
	print(mx - mn, n * (n - 1) // 2)
else:
	mx_c = b.count(mx)
	mn_c = b.count(mn)
	print(mx - mn, mx_c * mn_c)


n = int(input())
a = list(map(int, input().strip().split()))
a.sort()
mi = a[0]
ma = a[-1]
min_c = a.count(mi)
max_c = a.count(ma)
if mi == ma:
	print(0, n * (n - 1) // 2)
else:
	print(ma - mi, min_c * max_c)


n = int(input())
s = 0
s1 = 0
a = list(map(int, input().split()))
a.sort()
for i in range(len(a)):
	if a[i] == a[0]:
		s = s + 1
	else:
		break
for i in range(len(a) - 1, 0, -1):
	if a[i] == a[len(a) - 1]:
		s1 = s1 + 1
	else:
		break
if a[0] == a[len(a) - 1]:
	s1 = s1 + 1
if a[len(a) - 1] != a[0]:
	print(abs(a[len(a) - 1] - a[0]), s * s1)
else:
	print(abs(a[len(a) - 1] - a[0]), round(s * (s1 - 1) / 2))


n = int(input())
l = list(map(int, input().split()))
d = max(l) - min(l)
k = l.count(max(l)) * l.count(min(l))
if min(l) == max(l):
	n = l.count(min(l))
	k = (n - 1) * n // 2
print(d, k)


n = int(input())
arr = map(int, input().split())
arr = sorted(arr)
mini = arr[0]
maxi = arr[-1]
cnt1 = arr.count(mini)
cnt2 = arr.count(maxi)
if mini == maxi:
	print('0', ' ', n * (n - 1) // 2)
else:
	print(maxi - mini, ' ', cnt1 * cnt2)


def getValues():
	return list(map(int, input().split()))
n = int(input())
L = getValues()
L.sort()

def solve():
	a = 0
	b = 0
	for num in L:
		if num == L[0]:
			a += 1
		if num == L[-1]:
			b += 1
	diff = L[-1] - L[0]
	if diff == 0:
		return (diff, a * (a - 1) // 2)
	else:
		return (diff, a * b)
print(*solve())


n = int(input())
l = list(map(int, input().split()))
max = max(l)
min = min(l)
m = l.count(max)
if min == max:
	print(str(abs(max - min)) + ' ' + str(m * (m - 1) // 2))
else:
	print(str(abs(max - min)) + ' ' + str(m * l.count(min)))


n = int(input())
b = [int(_) for _ in input().split(' ')]
b.sort()
max_diff = b[-1] - b[0]
if max_diff == 0:
	print('0  ', str(int(n * (n - 1) / 2)))
else:
	k = 1
	while b[k] == b[0]:
		k += 1
	l = 1
	while b[-l - 1] == b[-1]:
		l += 1
	print(str(max_diff), ' ', str(k * l))


n = int(input())
b = [int(x) for x in input().split()]
b.sort()
p = 0
q = 0
if b[0] == b[-1]:
	print(0, n * (n - 1) // 2)
else:
	for x in b:
		if x == b[0]:
			p += 1
		elif x == b[-1]:
			q += 1
	print(b[-1] - b[0], p * q)


n = int(input())
lis = sorted(map(int, input().split()))
low = 0
high = 0
low = lis[0]
high = lis[-1]
if low != high:
	qnt1 = 1
	qnt2 = 1
	cont = 1
	while lis[cont] == low:
		qnt1 += 1
		cont += 1
	cont = -2
	while lis[cont] == high:
		qnt2 += 1
		cont -= 1
	print('{} {}'.format(high - low, qnt1 * qnt2))
else:
	print('{} {}'.format(0, n * (n - 1) // 2))


loop = int(input())
s = str(input())
e = s.split(' ')
for i in range(loop):
	e[i] = int(e[i])
maxDiff = max(e) - min(e)
countOne = 0
countTwo = 0
i = 0
e.sort()
while e[i] == e[0]:
	countOne += 1
	i += 1
	if i == loop:
		break
i = loop - 1
while e[i] == e[-1]:
	countTwo += 1
	i -= 1
	if i == 0:
		break
if maxDiff > 0:
	print(str(maxDiff) + ' ' + str(countOne * countTwo))
elif maxDiff == 0:
	print('0 ' + str(int((loop - 1) * loop / 2)))


n = int(input())
l = list(map(int, input().split()))
l.sort()
mx = l[-1] - l[0]
cnt = 0
s = list(set(l))
s.sort()
if len(s) == 1:
	k = n * (n - 1) // 2
	print(0, k)
elif len(s) == len(l):
	print(mx, 1)
else:
	a = l.count(s[0])
	b = l.count(s[-1])
	print(mx, a * b)


n = input()
n = int(n)
a = list(map(int, input().split()))
e = max(a)
f = min(a)
if e == f:
	print(0, n * (n - 1) // 2)
else:
	print(e - f, a.count(e) * a.count(f))


numberFlower = input()
numberFlower = int(numberFlower)
flowerPair = input()
flowerPair = flowerPair.split(' ')
for i in range(len(flowerPair)):
	flowerPair[i] = int(flowerPair[i])
maxDifference = max(flowerPair) - min(flowerPair)
repetitionMax = flowerPair.count(max(flowerPair))
repetitionMin = flowerPair.count(min(flowerPair))
if maxDifference != 0:
	pairNumber = repetitionMax * repetitionMin
elif maxDifference == 0:
	pairNumber = repetitionMax * (repetitionMax - 1) / 2
	pairNumber = int(pairNumber)
print(maxDifference, pairNumber)


n = int(input())
b = list(map(int, input().split(' ')))
(bmin, bmax) = (min(b), max(b))
(nbmin, nbmax) = (b.count(bmin), b.count(bmax))
print(bmax - bmin, n * (n - 1) // 2 if bmin == bmax else nbmin * nbmax)


n = int(input())
line = list(map(int, input().split()))
min_val = min(line)
max_val = max(line)
max_diff = max_val - min_val
if max_diff == 0:
	min_options = [i for i in line if i == min_val]
	n_combs = 0
	for i in range(n):
		n_combs += i
else:
	min_options = [i for i in line if i == min_val]
	max_options = [i for i in line if i == max_val]
	n_combs = len(max_options) * len(min_options)
print('{} {}'.format(max_diff, n_combs))


from sys import stdin

def iinput():
	return int(stdin.readline())

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))
n = iinput()
b = linput()
(mn, mx) = (min(b), max(b))
print(mx - mn, b.count(mn) * b.count(mx) if mx - mn != 0 else b.count(mn) * (b.count(mn) - 1) // 2)


n = int(input())
b = [[]] * n
i = 0
while i < n:
	b[i] = 0
	i += 1
i = 0
b = list(map(int, input().split(' ')))
m = min(b)
x = max(b)
dif = x - m
i = 0
(t_m, t_x) = (0, 0)
while i < n:
	if b[i] == x:
		t_x += 1
	if b[i] == m:
		t_m += 1
	i += 1
if m == x:
	if i > 2:
		print(dif, i * (i - 1) // 2)
	else:
		print(dif, m)
else:
	print(dif, t_m * t_x)


input()
l = sorted(map(int, input().split()))
a = l[0]
b = l[-1]
c = len(l)
print(b - a, a != b and l.count(a) * l.count(b) or c * (c - 1) // 2)


a = int(input())
b = list(map(int, input().split()))
m = max(b)
n = min(b)
ans1 = m - n
if b.count(b[0]) == a:
	ans2 = a * (a - 1) // 2
else:
	ans2 = b.count(m) * b.count(n)
print(ans1, ans2)


import atexit
import io
import sys
import bisect
_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B

@atexit.register
def write():
	sys.__stdout__.write(_O_B.getvalue())

def main():
	n = int(input())
	b = list(map(int, input().split()))
	bd = dict()
	for i in b:
		try:
			bd[i] += 1
		except KeyError:
			bd[i] = 1
	co = 0
	md = max(b) - min(b)
	if md == 0:
		for i in bd:
			co += bd[i] * (bd[i] - 1) // 2
	else:
		for i in bd:
			try:
				co += bd[i] * bd[i + md]
			except KeyError:
				co += 0
	print(md, co)
main()


input()

class Counter(dict):

	def __missing__(self, key):
		return 0
s = Counter()
for x in input().split():
	s[int(x)] += 1
k = list(s.keys())
k.sort()
if len(k) > 1:
	print(k[len(k) - 1] - k[0], s[k[len(k) - 1]] * s[k[0]])
else:
	print(0, int(s[k[0]] * (s[k[0]] - 1) / 2))


n = int(input())
a = list(map(int, input().split()))
print(max(a) - min(a), [n * (n - 1) // 2, a.count(max(a)) * a.count(min(a))][max(a) != min(a)])


ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
n = ii()
l = li()
d = max(l) - min(l)
print(d, l.count(max(l)) * l.count(min(l)) if d != 0 else n * (n - 1) // 2)


n = int(input())
a = [int(X) for X in input().split()]
x = a.count(min(a))
y = a.count(max(a))
print(max(a) - min(a), end=' ')
if min(a) != max(a):
	print(x * y)
else:
	print(x * (x - 1) // 2)


n = int(input())
b = sorted(map(int, input().split()))
print(b[-1] - b[0], b.count(b[0]) * b.count(b[-1]) if b[0] != b[-1] else n * (n - 1) // 2)


n = int(input())
a = [int(w) for w in input().split()]
a.sort()
if a[-1] - a[0] == 0:
	print(0, n * (n - 1) // 2)
else:
	print(a[-1] - a[0], a.count(a[0]) * a.count(a[-1]))


n = int(input())
lst = list(map(int, input().split()))
if min(lst) == max(lst):
	print(0, n * (n - 1) // 2)
else:
	print(max(lst) - min(lst), lst.count(max(lst)) * lst.count(min(lst)))


from math import factorial
n = int(input())
a = list(map(int, input().split()))
a.sort()
if len(set(a)) != 1:
	print(a[-1] - a[0], a.count(max(a)) * a.count(min(a)))
else:
	k = a.count(a[0])
	print(0, k * (k - 1) // 2)


from collections import Counter

def solve():
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	c = Counter(l)
	maxDiff = l[-1] - l[0]
	if maxDiff == 0:
		s = len(l)
		return (0, s * (s - 1) // 2)
	ans = 0
	for (k, v) in c.items():
		if k + maxDiff in c:
			ans += v * c[k + maxDiff]
		if k - maxDiff in c:
			ans += v * c[k - maxDiff]
	return (maxDiff, ans // 2)
(a, b) = solve()
print(a, b)


n = int(input())
l = list(map(int, input().split()))
x = max(l)
y = min(l)
if len(set(l)) == 1:
	print(0, n * (n - 1) // 2)
else:
	print(x - y, l.count(x) * l.count(y))


def read_input():
	input()
	splited_line = input().rstrip().split()
	return [int(_) for _ in splited_line]

def write_output(max_dist, count):
	print('%d %d' % (max_dist, count))

def get_result(flowers):
	flowers = sorted(flowers)
	max_dist = flowers[-1] - flowers[0]
	dist = max_dist
	(count_min, count_max) = (0, 0)
	n = len(flowers)
	if flowers[0] == flowers[-1]:
		return (max_dist, int(n * (n - 1) / 2))
	while flowers[count_min] == flowers[0]:
		count_min += 1
	while flowers[-1 - count_max] == flowers[-1]:
		count_max += 1
	return (max_dist, count_min * count_max)

def main():
	flowers = read_input()
	(max_dist, count) = get_result(flowers)
	write_output(max_dist, count)
main()


def getinput():
	return [int(i) for i in input().split()]
_ = input()
flowers = getinput()
mini = maxi = flowers[0]
for f in flowers:
	if f < mini:
		mini = f
	elif f > maxi:
		maxi = f
maxic = flowers.count(maxi)
minic = flowers.count(mini)
if maxi == mini:
	maxic -= 1
	comb = (maxic ** 2 + maxic) // 2
else:
	comb = minic * maxic
print(maxi - mini, comb)


b = int(input())
a = list(map(int, input().split()))
c = a.count(max(a))
d = a.count(min(a))
e = max(a) - min(a)
print(e, end=' ')
if max(a) == min(a):
	print(c * (c - 1) // 2)
else:
	print(c * d)


l = int(input())
s = list(map(int, input().split()))
ctr = 0
s.sort()
mx = max(s) - s[0]
nhigh = s.count(s[l - 1])
nlow = s.count(s[0])
ctr = nhigh * nlow
if s[l - 1] == s[0]:
	ctr = l * (l - 1) // 2
print(mx, ctr)


n = int(input())
l = list(map(int, input().split()))
print(max(l) - min(l), end=' ')
if min(l) != max(l):
	print(int(l.count(max(l)) * l.count(min(l))))
else:
	print(int(l.count(max(l)) * (l.count(max(l)) - 1) / 2))


input()
l = sorted(map(int, input().split()))
a = min(l)
b = max(l)
c = len(l)
print(b - a, a != b and l.count(a) * l.count(b) or c * (c - 1) // 2)


def solve(xs):
	xs.sort()
	ll = len(xs)
	max_diff = xs[-1] - xs[0]
	if max_diff == 0:
		count = ll * (ll - 1) // 2
	else:
		count = xs.count(xs[0]) * xs.count(xs[-1])
	return (max_diff, count)

def main():
	n = int(input())
	xs = [int(i) for i in input().strip().split()]
	assert len(xs) == n
	result = solve(xs)
	print(' '.join((str(n) for n in result)))
main()


from collections import Counter
n = int(input())
b = [int(x) for x in input().split()]
counter = sorted(Counter(b).items(), key=lambda x: x[0])
print(counter[-1][0] - counter[0][0], end=' ')
if len(counter) > 1:
	print(counter[-1][1] * counter[0][1])
else:
	print(counter[0][1] * (counter[0][1] - 1) // 2)


n = int(input())
a = [int(i) for i in input().split()]
if max(a) != min(a):
	print(max(a) - min(a), a.count(max(a)) * a.count(min(a)))
else:
	print(max(a) - min(a), n * (n - 1) // 2)


def PashmakAndFlowers(l):
	ma = max(l)
	mi = min(l)
	reMax = 0
	reMin = 0
	for x in l:
		if x == mi:
			reMin += 1
		elif x == ma:
			reMax += 1
	if ma == mi:
		print(ma - mi, ' ', reMin * (reMin - 1) // 2)
		return
	print(ma - mi, ' ', reMax * reMin)
input()
PashmakAndFlowers([int(x) for x in input().split()])


n = int(input())
flower = [int(i) for i in input().split()]
(a, b) = (max(flower), min(flower))
print(a - b, flower.count(a) * (flower.count(b) - (a == b)) // (1 + (a == b)))


from math import ceil
for _ in range(1):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	i = 0
	s = list(set(l))
	s.sort()
	d = l[n - 1] - l[0]
	cnt = 0
	res = 0
	j = len(s) - 1
	if d == 0:
		print(0, n * (n - 1) // 2)
	else:
		while i < len(s) and j >= 0:
			if s[j] - s[i] == d:
				m = l.count(s[i])
				n = l.count(s[j])
				res = res + m * n
			i = i + 1
			j = j - 1
		print(d, res)


F = lambda : int(input())
L = lambda : list(map(int, input().split()))
n = F()
l = L()
m = l.count(max(l))
ma = l.count(min(l))
if len(set(l)) == 1:
	print(0, n * (n - 1) // 2)
else:
	print(abs(min(l) - max(l)), m * ma)


n = int(input())
l = list(map(int, input().split()))
c = max(l)
d = min(l)
m = c - d
a = l.count(c)
b = l.count(d)
e = a * b
if m != 0:
	print(str(m) + ' ' + str(e))
else:
	e = a * (a - 1) // 2
	print(str(m) + ' ' + str(e))


n = int(input())
a = sorted(map(int, input().split()))
x = a[-1] - a[0]
f = a.count(a[0]) * a.count(a[-1])
if a[0] == a[-1]:
	f = a.count(a[0]) * (a.count(a[0]) - 1) // 2
print(x, f)


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
N = int(input())
B = [int(x) for x in input().split()]
(maxb, maxbcount, minb, minbcount) = (float('-inf'), 0, float('inf'), 0)
for b in B:
	if b > maxb:
		maxb = b
		maxbcount = 1
	elif b == maxb:
		maxbcount += 1
	if b < minb:
		minb = b
		minbcount = 1
	elif b == minb:
		minbcount += 1
if maxb == minb:
	print(0, maxbcount * (maxbcount - 1) // 2)
else:
	print(maxb - minb, maxbcount * minbcount)


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))
(n,) = mp()
b = mp()
mini = min(b)
maxi = max(b)
if mini == maxi:
	cout('0 ' + str(n * (n - 1) // 2))
else:
	cout(str(maxi - mini) + ' ' + str(b.count(mini) * b.count(maxi)))


n = int(input())
array = [int(i) for i in input().split()]
array.sort()
min = array[0]
max = array[n - 1]
count_min = 0
count_max = 0
for i in range(n):
	if array[i] == min:
		count_min += 1
	elif array[i] == max:
		count_max += 1
difference = max - min
combinations = count_max * count_min
if combinations == 0:
	combinations = count_min * (count_min - 1) / 2
print('%d %d' % (difference, combinations))


n = int(input())
b = list(map(int, input().split()))
b.sort()
nmin = 0
nmax = 0
mini = b[0]
maxi = b[n - 1]
k = 0
if mini != maxi:
	for i in range(n):
		if b[i] > mini and k == 0:
			nmin = i
			k = 1
		if b[i] == maxi:
			nmax = n - i
			break
	print(maxi - mini, nmin * nmax)
else:
	print(maxi - mini, int((n - 1) * n / 2))


n = int(input())
string = input().split()
num = []
for i in string:
	num.append(int(i))
num.sort()
result = str(num[len(num) - 1] - num[0]) + ' '
if num[0] != num[len(num) - 1]:
	small_no = 1
	for i in range(len(num) - 1):
		if num[i + 1] != num[i]:
			break
		else:
			small_no += 1
	large_no = 1
	for i in range(len(num) - 1, -1, -1):
		if num[i - 1] != num[i]:
			break
		else:
			large_no += 1
	result += str(small_no * large_no)
else:
	i = 1
	sum = 0
	while i < len(num):
		sum += i
		i += 1
	result += str(sum)
print(result)


def solve():
	if max_diff == 0:
		return n * (n - 1) // 2
	c1 = 0
	p1 = 0
	while True:
		if menor == b[p1]:
			c1 += 1
			p1 += 1
		else:
			break
		if p1 == n:
			break
	c2 = 0
	p2 = n - 1
	while True:
		if maior == b[p2]:
			c2 += 1
			p2 -= 1
		else:
			break
		if p2 == -1:
			break
	return c1 * c2
n = int(input())
b = [int(x) for x in input().split()]
b.sort()
maior = b[-1]
menor = b[0]
max_diff = maior - menor
print(max_diff, solve())


import math, sys
from collections import Counter

def li():
	return list(map(int, sys.stdin.readline().split()))

def ls():
	return list(map(int, list(input())))

def la():
	return list(input())

def ii():
	return int(input())

def isPrime(n):
	i = 2
	if n == 1:
		return False
	while i <= int(math.sqrt(n)):
		if n % i == 0:
			return False
		i = i + 1
	return True

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
n = ii()
a = li()
x = max(a) - min(a)
count = 0
dic = Counter(a)
a = sorted(dic.keys())
maxx = a.index(max(a))
minn = a.index(min(a))
while maxx >= 0 and minn >= 0:
	if maxx == minn:
		count += n * (n - 1) // 2
	else:
		count += dic[a[maxx]] * dic[a[minn]]
	maxx -= 1
	minn -= 1
print(x, count)


import math
mn = math.inf
mx = 0
n = int(input())
b = [int(x) for x in input().split()]
for i in b:
	mx = max(mx, i)
	mn = min(mn, i)
t1 = 0
t2 = 0
for i in b:
	if mx == i:
		t1 += 1
	elif mn == i:
		t2 += 1
print(mx - mn, end=' ')
if mx == mn:
	print(n * (n - 1) // 2)
else:
	print(t1 * t2)


n = int(input())
a = list(map(int, input().split(' ')))
b = a.count(max(a))
c = a.count(min(a))
if len(set(a)) == 1:
	print(f'{max(a) - min(a)} {(n - 1) * n // 2}')
else:
	print(f'{max(a) - min(a)} {b * c}')


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
print(arr[-1] - arr[0], end=' ')
ways = arr.count(arr[0]) * arr.count(arr[-1]) if arr[0] != arr[-1] else n * (n - 1) >> 1
print(ways)


def solve(n, b):
	(mn, mx) = (0, 0)
	b.sort()
	for i in range(0, n, 1):
		if b[i] != b[0]:
			break
		mn += 1
	for i in range(n - 1, 0 - 1, -1):
		if b[i] != b[n - 1]:
			break
		mx += 1
	if b[n - 1] == b[0]:
		res = res = [b[n - 1] - b[0], mn * (mx - 1) // 2]
	else:
		res = [b[n - 1] - b[0], mn * mx]
	return res

def pashmak_and_flowers(n, b):
	return solve(n, b)
n = int(input())
b = list(map(int, input().split()))
print(*pashmak_and_flowers(n, b))


n = int(input())
b = list(map(int, input().split()))
a = max(b)
i = min(b)
if i != a:
	second = b.count(a) * b.count(i)
else:
	second = int(n * (n - 1) / 2)
print(a - i, second)


n = int(input())
a = list(map(int, input().split()))
s = max(a) - min(a)
x1 = a.count(min(a))
x2 = a.count(max(a))
if x1 == x2 == n:
	print(s, end=' ')
	print(n * (n - 1) // 2)
else:
	print(s, end=' ')
	print(x1 * x2)


n = int(input())
a = sorted(map(int, input().split()))
z = a.count(a[0])
x = a.count(a[-1])
if a[-1] == a[0]:
	print(0, n * (n - 1) // 2)
else:
	print(a[-1] - a[0], z * x)


n = int(input())
list1 = [int(x) for x in input().split(' ')]
min1 = min(list1)
max1 = max(list1)
count1 = list1.count(min1)
count2 = list1.count(max1)
if min1 == max1:
	print(max1 - min1, end=' ')
	print(int(count1 * (count1 - 1) / 2))
else:
	print(max1 - min1, end=' ')
	print(count1 * count2)


n = int(input())
b = sorted(map(int, input().split()))
x = len(list(filter(lambda a: a == b[0], b)))
y = len(list(filter(lambda a: a == b[-1], b)))
print(f'{b[-1] - b[0]} {(x * y if b[0] != b[-1] else (n - 1) * n // 2)}')


def flowers(f):
	lowest = float('inf')
	highest = 0
	lowc = 0
	highc = 0
	for n in f:
		if n < lowest:
			lowest = n
			lowc = 1
		elif n == lowest:
			lowc = lowc + 1
		if n > highest:
			highest = n
			highc = 1
		elif n == highest:
			highc = highc + 1
	if highest == lowest:
		n = len(f)
		print(0, int(n * (n - 1) / 2))
	else:
		print(highest - lowest, lowc * highc)
_ = input()
flowers([int(x) for x in input().split(' ')])


n = int(input())
ar = input().split()
for i in range(0, n):
	ar[i] = int(ar[i])
ar.sort()
c1 = 0
c2 = 0
for i in range(0, n):
	if ar[i] == ar[0]:
		c1 += 1
for i in range(0, n):
	if ar[n - 1 - i] == ar[n - 1]:
		c2 += 1
if c1 == n:
	y = c1 * (c2 - 1) // 2
else:
	y = c1 * c2
print(ar[n - 1] - ar[0], y)


def f(n=2):
	return int(n * (n - 1) / 2)
n = int(input())
flowers_mas = sorted([int(i) for i in input().split()])
min = int(flowers_mas[0])
min_c = flowers_mas.count(flowers_mas[0])
max = int(flowers_mas[len(flowers_mas) - 1])
max_c = flowers_mas.count(flowers_mas[len(flowers_mas) - 1])
dif = int(abs(max - min))
if not max == min:
	print(dif, max_c * min_c)
else:
	print(0, f(n))


n = int(input())
b = list(map(int, input().split()))
mx = max(b)
mn = min(b)
if mx == mn:
	c = b.count(mx)
	print(0, c * (c - 1) // 2)
else:
	print(mx - mn, b.count(mx) * b.count(mn))


import math

def nummin(f):
	c = 0
	m = 99999999999
	for n in f:
		if n < m:
			m = n
			c = 1
		elif n == m:
			c += 1
	return (m, c)

def nummax(f):
	c = 0
	m = -1
	for n in f:
		if n > m:
			m = n
			c = 1
		elif n == m:
			c += 1
	return (m, c)
numflowers = int(input())
flowers = list(map(int, input().split()))
(minvalue, mincount) = nummin(flowers)
(maxvalue, maxcount) = nummax(flowers)
diff = maxvalue - minvalue
perms = 0
if minvalue == maxvalue:
	for i in range(1, mincount):
		perms += i
else:
	perms = mincount * maxcount
print('{} {}'.format(diff, perms))


n = int(input())
a = list(map(int, input().split(' ')))
kmx = a.count(max(a))
kmn = a.count(min(a))
if max(a) == min(a):
	kmx = int(kmx * (kmx - 1) / 2)
	kmn = 1
print(max(a) - min(a), kmx * kmn)


import sys
import math
import os
t = int(input())
data = list(map(int, input().split()))
data.sort()
countMin = 0
countMax = 0
for i in range(t):
	if i >= 1 and data[i] != data[i - 1]:
		break
	countMin += 1
for i in range(t):
	if i == 0:
		continue
	if -i < -1 and data[-i] != data[-i + 1]:
		break
	countMax += 1
if data[-1] != data[0]:
	print(abs(data[-1] - data[0]), countMax * countMin)
else:
	print(0, int(t * (t - 1) / 2))


n = int(input())
b = [int(i) for i in input().split()]
b.sort()
big = b[n - 1]
small = b[0]
n_big = b.count(big)
n_small = b.count(small)
max_bdif = big - small
ways = n_big * n_small
if big == small:
	ways = n_big * (n_big - 1) // 2
print(max_bdif, ways)


n = int(input(''))
arr = list(map(int, input().split()))
arr.sort()
boro = arr[n - 1]
choto = arr[0]
if choto == boro:
	d = arr.count(choto)
	print(0, d * (d - 1) // 2)
else:
	b = arr.count(boro)
	c = arr.count(choto)
	print(boro - choto, b * c)


n = int(input())
a = list(map(int, input().split()))
count1 = 0
count2 = 0
if len(set(a)) > 1:
	a.sort()
	for i in range(n):
		if a[i] == a[0]:
			count1 += 1
		if a[n - 1] == a[i]:
			count2 += 1
	print(a[n - 1] - a[0], count1 * count2)
else:
	count = 0
	for i in range(1, n):
		count += i
	print(0, count)


T = int(input())
caption = list(map(int, input().split()))
n = len(caption)
maxb = max(caption)
minb = min(caption)
ans0 = maxb - minb
num_max = num_min = 0
for i in caption:
	if i == maxb:
		num_max += 1
	elif i == minb:
		num_min += 1
if ans0 == 0:
	ans1 = n * (n - 1) // 2
else:
	ans1 = num_max * num_min
print(ans0, ans1)


input()
b = [int(i) for i in input().split()]
maximum = max(b)
minimum = min(b)
max_diff = maximum - minimum
if max_diff != 0:
	permutations = b.count(maximum) * b.count(minimum)
else:
	n = b.count(maximum)
	permutations = n * (n - 1) // 2
print(max_diff, permutations)


_ = input()
arr = list(map(int, input().split()))
mi = [arr[0], 1]
ma = [arr[0], 1]
for f in arr[1:]:
	if f < mi[0]:
		mi = [f, 0]
	if f > ma[0]:
		ma = [f, 0]
	if f == mi[0]:
		mi[1] += 1
	if f == ma[0]:
		ma[1] += 1
if mi[0] == ma[0]:
	print('0 {}'.format(len(arr) * (len(arr) - 1) // 2))
else:
	print('{} {}'.format(ma[0] - mi[0], ma[1] * mi[1]))


import sys
from os import path
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
n = int(input())
b = list(map(int, input().split()))
h = max(b)
l = min(b)
if h == l:
	print(0, n * (n - 1) // 2)
else:
	zz = b.count(h) * b.count(l)
	print(h - l, zz)


try:
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = l[n - 1] - l[0]
	a = l.count(l[n - 1])
	b = l.count(l[0])
	m = list(set(l))
	if len(m) == 1:
		print(0, n * (n - 1) // 2)
	else:
		print(ans, a * b)
except:
	pass


n = int(input())
l = [int(x) for x in input().split()]
l.sort()
if n == 2:
	print(l[1] - l[0], '1')
else:
	(i, x) = (1, 1)
	while i < n and l[i] == l[0]:
		x += 1
		i += 1
	(i, y) = (n - 2, 1)
	while i >= 0 and l[i] == l[n - 1]:
		y += 1
		i -= 1
	if x == y and y == n:
		print('0', int(n * (n - 1) / 2))
	else:
		print(l[n - 1] - l[0], x * y)


n = int(input())
flores = list(map(int, input().split()))
cont = {}
minv = 0
maxv = 0
for i in range(n):
	if flores[i] < flores[minv]:
		minv = i
	if flores[i] > flores[maxv]:
		maxv = i
	if flores[i] in cont:
		cont[flores[i]] += 1
	else:
		cont[flores[i]] = 1
diff = flores[maxv] - flores[minv]
ans = cont[flores[minv]] * cont[flores[maxv]]
if minv == maxv:
	ans = cont[flores[minv]] * (cont[flores[maxv]] - 1) // 2
print(diff, ans)


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
b = a[0]
c = a[-1]
if b != c:
	print(c - b, a.count(b) * a.count(c))
else:
	r = a.count(b)
	print(0, r * (r - 1) // 2)


n = int(input().strip())
arr = list(map(int, input().strip().split()))
arr.sort()
maxDiff = arr[-1] - arr[0]
if arr[-1] == arr[0]:
	noOfWays = n * (n - 1) // 2
else:
	noOfWays = arr.count(arr[-1]) * arr.count(arr[0])
print(maxDiff, noOfWays)


n = int(input())
b = list(map(int, input().split()))
b.sort()
k = b[-1] - b[0]
if b[0] == b[-1]:
	m = max(1, (b.count(b[0]) - 1) * b.count(b[0]) // 2)
else:
	m = b.count(b[0]) * b.count(b[-1])
print(k, m)


n = int(input())
l = sorted(list(map(int, input().split())))
if l[0] == l[n - 1]:
	print(0, int(n * (n - 1) / 2))
else:
	print(int(l[n - 1] - l[0]), int(l.count(l[0]) * l.count(l[n - 1])))


n = int(input())
arr = input().split()
arr = [int(x) for x in arr]
arr.sort()
minval = arr[0]
maxval = arr[len(arr) - 1]
print(maxval - minval, arr.count(maxval) * (arr.count(maxval) - 1) // 2 if maxval == minval else arr.count(maxval) * arr.count(minval))


n = int(input())
b = list(map(int, input().split()))
l = max(b)
s = min(b)
diff = l - s
if diff == 0:
	print('%d %d' % (0, n * (n - 1) // 2))
else:
	large = 0
	small = 0
	for i in b:
		if i == l:
			large += 1
		elif i == s:
			small += 1
	print('%d %d' % (diff, large * small))


def solve(alist):
	maxElem = alist[0]
	maxElemCount = 1
	minElem = alist[0]
	minElemCount = 1
	maxDiff = 0
	options = 0
	for i in range(1, len(alist)):
		if alist[i] > maxElem:
			maxElem = alist[i]
			maxElemCount = 1
		elif alist[i] == maxElem:
			maxElemCount += 1
		if alist[i] < minElem:
			minElem = alist[i]
			minElemCount = 1
		elif alist[i] == minElem:
			minElemCount += 1
	maxDiff = maxElem - minElem
	options = maxElemCount * minElemCount
	if maxDiff == 0:
		import math
		val = math.sqrt(options)
		options = int(val * (val - 1) / 2)
	return '{} {}'.format(maxDiff, options)
n = int(input())
b = list(map(int, input().split(' ')))
print(solve(b))


n = int(input())
nn = list(map(int, input().rstrip().split()))
nn.sort()
minn = nn[0]
maxx = nn[-1]
countmax = 0
countmin = 0
for i in range(n):
	if nn[i] == minn:
		countmin += 1
	if nn[i] == maxx:
		countmax += 1
if maxx != minn:
	print(maxx - minn, end=' ')
	print(countmax * countmin)
else:
	print(0, '', int(n * (n - 1) / 2))


t = 1
while t > 0:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	minn = min(l)
	maxx = max(l)
	a = l.count(minn)
	b = l.count(maxx)
	if minn == maxx:
		print(0, n * (n - 1) // 2)
	else:
		print(maxx - minn, a * b)


n = int(input())
m = list((int(x) for x in input().split()))
a = max(m)
z = min(m)
ac = m.count(a)
az = m.count(z)
daz = a - z
if daz:
	dc = ac * az
else:
	dc = 0
	for i in range(ac):
		dc += i
print(daz, dc)


import bisect
import math
n = map(int, input().split())
b = list(map(int, input().split()))
b.sort()
if b[0] == b[-1]:
	print(0, len(b) * (len(b) - 1) // 2)
else:
	print(b[-1] - b[0], bisect.bisect_right(b, b[0]) * (len(b) - bisect.bisect_left(b, b[-1])))


n = int(input())
l = list(map(int, input().split()))
c1 = max(l)
c2 = min(l)
if c1 == c2:
	print(abs(c1 - c2), ' ', int(n * ((n - 1) / 2)))
else:
	print(abs(c1 - c2), ' ', l.count(c1) * l.count(c2))


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
i1 = arr[-1] - arr[0]
M = 0
m = 0
for i in range(n):
	if arr[i] == arr[0]:
		m += 1
	elif arr[i] == arr[-1]:
		M += 1
if m == n:
	i2 = n * (n - 1) // 2
else:
	i2 = M * m
print(i1, i2)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans
from math import *
for _ in range(1):
	n = int(input())
	cnt = 0
	num = list(map(int, input().split()))
	num.sort()
	ans = num[-1] - num[0]
	cc = dict()
	for i in num:
		cc.setdefault(i, 0)
		cc.setdefault(i - ans, 0)
		cc[i] += 1
	num = set(num)
	if ans != 0:
		for i in num:
			if i > ans:
				cnt += cc[i] * cc[i - ans]
	else:
		for i in num:
			cnt += (cc[i] - 1) * cc[i] // 2
	print(ans, cnt)


n = int(input())
a = [int(x) for x in input().split()]
mxm = max(a)
minm = min(a)
if len(set(a)) == 1:
	print(mxm - minm, int(n * (n - 1) / 2))
else:
	print(mxm - minm, a.count(mxm) * a.count(minm))


n = int(input())
a = input().split()
for i in range(n):
	a[i] = int(a[i])
diff = max(a) - min(a)
if diff != 0:
	count = a.count(max(a)) * a.count(min(a))
else:
	count = n * (n - 1) // 2
print(diff, count)


n = int(input())
b = list(map(int, input().split()))
if len(set(b)) == 1:
	print(0, n * (n - 1) // 2)
	exit()
(mn, mx) = (min(b), max(b))
print(mx - mn, b.count(mn) * b.count(mx))


def main():
	n = int(input())
	l = list(map(int, input().split(' ')))
	maximal = 0
	minimal = 1000000001
	for x in l:
		maximal = max(maximal, x)
		minimal = min(minimal, x)
		pass
	if maximal == minimal:
		print('0 %d' % (n * (n - 1) / 2))
		return
		pass
	nmin = 0
	nmax = 0
	for x in l:
		if x == minimal:
			nmin += 1
			pass
		if x == maximal:
			nmax += 1
			pass
		pass
	pass
	print('%d %d' % (maximal - minimal, nmax * nmin))
main()


n = int(input())
b = [int(i) for i in input().split()]

def fact(n):
	x = 1
	for i in range(1, n + 1):
		x *= i
	return x
b.sort()
res1 = b[-1] - b[0]
count1 = 0
count2 = 0
if b[0] == b[-1]:
	res2 = int(n * (n - 1) / 2)
else:
	for a in b:
		if a == b[0]:
			count1 += 1
		if a == b[-1]:
			count2 += 1
	res2 = count1 * count2
print(res1, res2)


n = int(input())
l = [int(x) for x in input().split()]
l.sort()
mi = l.count(l[0])
ma = l.count(l[n - 1])
x = l[n - 1] - l[0]
if mi == n:
	y = mi * (mi - 1) / 2
else:
	y = ma * mi
print(x, int(y), end=' ')


n = int(input())
lst = list((int(num) for num in input().split()))[:n]
diff = max(lst) - min(lst)
if diff == 0:
	way = n * (n - 1) / 2
else:
	a = lst.count(max(lst))
	b = lst.count(min(lst))
	way = a * b
print(diff, int(way))


n = int(input())
l = list(map(int, input().split()))
d = max(l) - min(l)
if d != 0:
	print(d, l.count(min(l)) * l.count(max(l)))
else:
	print(d, n * (n - 1) // 2)


n = int(input())
l = list(map(int, input().split()))
a = max(l)
b = min(l)
p = a - b
if a == b:
	print(0, n * (n - 1) // 2)
else:
	print(p, end=' ')
	print(l.count(a) * l.count(b))


n = int(input())
L = sorted([int(i) for i in input().split()], reverse=True)
if max(L) == min(L):
	print(0, n * (n - 1) // 2)
else:
	c1 = L.count(max(L))
	c2 = L.count(min(L))
	print(max(L) - min(L), c1 * c2)


from collections import Counter
n = input()
arr = list(map(int, input().split()))
mx = max(arr)
mn = min(arr)
diff = mx - mn
c = Counter(arr)
mxes = c[mx]
mnes = c[mn]
result = 0
if mx != mn:
	result = mxes * mnes
else:
	result = int(mxes * (mxes - 1) / 2)
print(str(diff) + ' ' + str(result))


n = int(input())
li = [int(x) for x in input().split()]
maxi = max(li)
mini = min(li)
if maxi == mini:
	print(0, int((n - 1) * n / 2))
else:
	c1 = li.count(maxi)
	c2 = li.count(mini)
	print(maxi - mini, c1 * c2)


n = int(input())
mp = {}
mx = int(-1000000000.0)
cmx = 0
mn = int(1000000000.0)
cmn = 0
for i in input().split():
	i = int(i)
	if i > mx:
		mx = i
		cmx = 1
	elif i == mx:
		cmx += 1
	if i < mn:
		mn = i
		cmn = 1
	elif i == mn:
		cmn += 1
if mn == mx:
	print(0, cmx * (cmx - 1) // 2)
else:
	print(mx - mn, cmx * cmn)


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
first = a.count(a[0])
last = a.count(a[len(a) - 1])
if a[0] == a[len(a) - 1]:
	print(a[len(a) - 1] - a[0], int(first * (first - 1) / 2))
else:
	print(a[len(a) - 1] - a[0], first * last)


x = list(input())
lst = list(map(int, input().split()))
maxx = max(lst)
minn = min(lst)
max_count = lst.count(maxx)
min_count = lst.count(minn)
if maxx == minn:
	print(maxx - minn, max_count * (max_count - 1) // 2)
else:
	print(maxx - minn, max_count * min_count)


n = int(input())
a = [int(j) for j in input().split()]
minA = min(a)
maxA = max(a)
print(maxA - minA, end=' ')
if minA != maxA:
	print(a.count(maxA) * a.count(minA))
else:
	s = a.count(minA)
	print(s * (s - 1) // 2)


a = int(input())
k = sorted(list(map(int, input().split())))
c = max(k) - min(k)
print(c, [a * (a - 1) // 2, k.count(max(k)) * k.count(min(k))][c != 0])


from collections import Counter
n = int(input())
b = list(map(int, input().split()))
d = Counter(b)
min1 = min(b)
max1 = max(b)
if max1 == min1:
	print(0, n * (n - 1) // 2)
	exit()
diff = max1 - min1
no_ways = d[max1] * d[min1]
print(diff, no_ways)


import sys
num = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
mx = max(arr)
mn = min(arr)
diff = mx - mn
if diff == 0:
	sys.stdout.write(str(diff) + ' ' + str(num * (num - 1) // 2))
	exit()
mx = arr.count(mx)
mn = arr.count(mn)
sys.stdout.write(str(diff) + ' ' + str(mx * mn))


n = int(input())
b = [int(i) for i in input().split()]
maxb = max(b)
minb = min(b)
if maxb != minb:
	print(maxb - minb, b.count(maxb) * b.count(minb))
else:
	print(maxb - minb, int(b.count(maxb) * (b.count(minb) - 1) / 2))


n = int(input())
a = sorted(list(map(int, input().split())))
mins = a.count(a[0])
maxs = a.count(a[-1])
if a[0] != a[-1]:
	total = mins * maxs
else:
	total = n * (n - 1) // 2
print(a[-1] - a[0], total)


t = int(input())
d = {}
l = list(map(int, input().split()))
for i in range(t):
	if l[i] in d:
		d[l[i]] += 1
	else:
		d[l[i]] = 1
print(max(l) - min(l), end=' ')
if max(l) == min(l):
	print(t * (t - 1) // 2)
else:
	print(d[max(l)] * d[min(l)])


def read():
	inputs = input().strip()
	return list(map(int, inputs.split()))
n = int(input())
a = sorted(read())
x = a.count(a[0])
y = a.count(a[n - 1])
if a[0] == a[n - 1]:
	print(a[n - 1] - a[0], n * (n - 1) // 2)
else:
	print(a[n - 1] - a[0], x * y)


el = int(input())
ar = []
maxNum = 0
minNum = 0
maxCount = 0
minCount = 0
ch = 0
for i in input().split(' '):
	temp = int(i)
	if ch != 0:
		if temp > maxNum:
			maxNum = temp
			maxCount = 1
		elif temp == maxNum:
			maxCount = maxCount + 1
		if temp < minNum:
			minNum = temp
			minCount = 1
		elif temp == minNum:
			minCount = minCount + 1
	else:
		maxNum = temp
		minNum = temp
		minCount = 1
		maxCount = 1
		ch = 1
if maxNum != minNum:
	print(maxNum - minNum, maxCount * minCount)
else:
	print(0, int(maxCount * (maxCount - 1) / 2))


n = int(input())
l = list(map(int, input().split()))
ma = max(l)
mi = min(l)
if ma == mi:
	co = l.count(ma)
	print(0, co * (co - 1) // 2)
else:
	print(ma - mi, l.count(ma) * l.count(mi))


from itertools import permutations
n = int(input())
l = []
l = list(map(int, input().split()))
l.sort()
d = l[-1] - l[0]
if l[-1] != l[0]:
	c = l.count(l[-1]) * l.count(l[0])
else:
	a = l.count(l[0])
	c = a * (a - 1) // 2
print(d, c)


n = int(input())
l = list(map(int, input().split(' ')))
mx = 0
mn = 1000000007
c0 = c1 = 0
for i in range(len(l)):
	if l[i] > mx:
		mx = l[i]
	if l[i] < mn:
		mn = l[i]
for i in range(len(l)):
	if mx == l[i]:
		c1 += 1
	if mn == l[i]:
		c0 += 1
print(mx - mn, end=' ')
if mn == mx:
	s = 0
	for i in range(1, c1):
		s += i
	print(s)
else:
	print(c0 * c1)


ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
si = lambda : input()
n = ii()
l = sorted(li())
(mi, ma) = (min(l), max(l))
(mic, mac) = (l.count(mi), l.count(ma))
if mi == ma:
	print(0, mic * (mic - 1) // 2)
else:
	print(ma - mi, mic * mac)


from collections import Counter as count
n = int(input())
z = [int(i) for i in input().split()]
s = count(z)
(x, y) = (min(z), max(z))
if x == y:
	print(0, s[x] * (s[x] - 1) // 2)
else:
	print(y - x, s[x] * s[y])


n = int(input())
l = [int(x) for x in input().split()]
M = max(l)
m = min(l)
McoN = 0
mcoN = 0
for i in l:
	if i == M:
		McoN += 1
	elif i == m:
		mcoN += 1
print(M - m, end=' ')
if M == m:
	print(n * (n - 1) // 2)
else:
	print(mcoN * McoN)


n = int(input())
bi = [int(x) for x in input().split()]
biSorted = sorted(bi)
maxVal = biSorted[-1]
minVal = biSorted[0]
maxDiff = maxVal - minVal
if maxDiff == 0:
	ans = int(n * (n - 1) / 2)
else:
	nMin = n - biSorted.index(maxVal)
	nMax = n - biSorted[::-1].index(minVal)
	ans = nMin * nMax
print(maxDiff, ans)


import math

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	b = [int(x) for x in input().split()]
	return (n, m, b)

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
(n, a) = na()
a = sorted(a)
mx = a[-1] - a[0]
mn = 0
km = 0
for i in range(n):
	if a[i] == a[0]:
		mn += 1
	else:
		break
for i in range(n - 1, -1, -1):
	if a[i] == a[-1]:
		km += 1
	else:
		break
if a[0] != a[-1]:
	print(mx, km * mn)
else:
	print(mx, n * (n - 1) // 2)


def main():
	n = int(input())
	ar = [int(i) for i in input().split()]
	if ar.count(ar[0]) == n:
		return print(0, n * (n - 1) // 2)
	else:
		return print(max(ar) - min(ar), ar.count(max(ar)) * ar.count(min(ar)))
	print(ma, count)
	return 0
main()


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
b = a[0]
c = a[len(a) - 1]
k = 0
l = 0
for i in range(len(a)):
	if a[i] == b:
		k += 1
	else:
		break
for i in range(len(a) - 1, -1, -1):
	if a[i] == c:
		l += 1
	else:
		break
if b == c:
	p = 0
	for i in range(1, len(a), 1):
		p += i
	print(0, p)
else:
	print(c - b, k * l)


a = int(input())
l = list(map(int, input().split()))
d = dict()
s = set()
for i in l:
	if i not in s:
		d[i] = 1
		s.add(i)
	else:
		d[i] += 1
max = max(l)
min = min(l)
raz = max - min
ans = 0
for i in l:
	x = i - raz
	if x in s:
		ans += d[x]
if raz == 0:
	print(0, a * (a - 1) // 2)
else:
	print(raz, ans)


n = int(input())
B = input()
b = []
for i in B.split():
	b.append(int(i))
b1 = max(b)
b2 = min(b)
ans1 = b1 - b2
countmax = 0
countmin = 0
for i in b:
	if i == b1:
		countmax += 1
	if i == b2:
		countmin += 1
if b1 == b2:
	ans2 = int(len(b) * (len(b) - 1) / 2)
else:
	ans2 = countmax * countmin
print('{0} {1}'.format(ans1, ans2))


__author__ = '-'
n = int(input())
lilled = [int(x) for x in input().split(' ')]
vahim = min(lilled)
suurim = max(lilled)
vastus = 0
if vahim == suurim:
	vastus = n * (n - 1) / 2
else:
	vahimat = lilled.count(vahim)
	suurimat = lilled.count(suurim)
	vastus = suurimat * vahimat
print(str(suurim - vahim) + ' ' + str(int(vastus)))


n = int(input())
a = sorted(list(map(int, input().split())))
i = a[0]
j = a[-1]
if i != j:
	c = a.count(i) * a.count(j)
else:
	c = n * (n - 1) // 2
print(j - i, c)


n = int(input())
flowers = input().split()
count = {}
min_flower = 0
max_flower = 0
for i in range(n):
	flowers[i] = int(flowers[i])
	if flowers[i] < flowers[min_flower]:
		min_flower = i
	if flowers[i] > flowers[max_flower]:
		max_flower = i
	if flowers[i] in count:
		count[flowers[i]] += 1
	else:
		count[flowers[i]] = 1
difference = flowers[max_flower] - flowers[min_flower]
result = count[flowers[min_flower]] * count[flowers[max_flower]]
if min_flower == max_flower:
	result = count[flowers[min_flower]] * (count[flowers[max_flower]] - 1) // 2
print(difference, result)


N = int(input())
L = input()
L = L.split()
for k in range(N):
	L[k] = int(L[k])
Min = min(L)
Max = max(L)
MaximaDif = Max - Min
Minimos = []
Maximos = []
for k in range(N):
	if L[k] == Min:
		Minimos.append(L[k])
	elif L[k] == Max:
		Maximos.append(L[k])
m = len(Minimos)
M = len(Maximos)
if M == 0:
	print(MaximaDif, m * (m - 1) // 2)
else:
	Formas = len(Minimos) * len(Maximos)
	print(MaximaDif, Formas)


def main():
	n = input()
	data = [int(x) for x in input().split()]
	_min = min(data)
	_max = max(data)
	if _min == _max:
		print(0, sum(range(data.count(_min))))
	else:
		print(_max - _min, data.count(_max) * data.count(_min))
main()


from collections import Counter
n = int(input())
flowers = sorted([int(v) for v in input().split()])
cnt = Counter(flowers)
(min_el, max_el) = (flowers[0], flowers[-1])
(mi, ma) = (cnt[min_el], cnt[max_el])
print(max_el - min_el, mi * ma if max_el != min_el else n * (n - 1) // 2)


n = int(input())
L = list(map(int, input().split()))
L = sorted(L)
i = 1
j = 1
while i < len(L) and L[i] == L[0]:
	i = i + 1
while len(L) - j - 1 >= 0 and L[len(L) - j - 1] == L[len(L) - 1]:
	j = j + 1
print(L[len(L) - 1] - L[0], end=' ')
if L[0] != L[len(L) - 1]:
	print(i * j)
else:
	print(i * (i - 1) // 2)


n = int(input())
a = list(map(int, input().split()))
a.sort()
(n1, n2) = (a[0], a[-1])
i2 = a.index(n2)
a.reverse()
i1 = a.index(n1)
c1 = len(a) - i1
c2 = len(a) - i2
if n1 == n2:
	print(0, n * (n - 1) // 2)
else:
	print(n2 - n1, c1 * c2)


n = int(input())
lis = [int(x) for x in input().split()]
lis.sort()
maxx = lis[-1] - lis[0]
count = lis.count(lis[0]) * lis.count(lis[-1])
if maxx != 0:
	print(maxx, count)
else:
	print(maxx, n * (n - 1) // 2)


n = int(input())
b = list(map(int, input().split()))
b.sort()
d = b[n - 1] - b[0]
mn = b.count(b[0])
mx = b.count(b[n - 1])
if d == 0:
	print(d, n * (n - 1) // 2)
else:
	print(d, mn * mx)


k = int(input())
c = list(map(int, input().split()))
p = dict()
m = c[0]
n = c[0]
p[m] = 1
for i in range(1, k):
	if c[i] > m:
		m = c[i]
		p[m] = 1
	elif c[i] == m:
		p[m] += 1
	elif c[i] < n:
		n = c[i]
		p[n] = 1
	elif c[i] == n:
		p[n] += 1
if m != n:
	print(m - n, p[n] * p[m])
else:
	print(0, p[n] * (p[n] - 1) // 2)


n = int(input())
sl = list(map(int, input().strip().split()))
k = min(sl)
m = max(sl)
s1 = sl.count(k)
s2 = sl.count(m)
if m - k == 0:
	print(m - k, (len(sl) - 1) * n // 2)
else:
	print(m - k, s1 * s2)


n = int(input())
l1 = list(map(int, input().split()))
l1.sort()
if l1[0] != l1[n - 1]:
	print(l1[n - 1] - l1[0], l1.count(l1[0]) * l1.count(l1[n - 1]))
else:
	print(0, l1.count(l1[0]) * (l1.count(l1[0]) - 1) // 2)


input()
ls = list(map(int, input().split()))
a = min(ls)
b = max(ls)
ca = cb = 0
for x in ls:
	if x == a:
		ca += 1
	if x == b:
		cb += 1
if a == b:
	print(0, ca * (ca - 1) // 2)
else:
	print(b - a, cb * ca)


n = int(input())
line = list(map(int, input().split()))
line.sort()
a = line[-1] - line[0]
if a != 0:
	cou = line.count(line[-1]) * line.count(line[0])
else:
	cou = n * (n - 1) // 2
print(a, cou)


n = int(input())
lst = list(map(int, input().strip().split(' ')))
m1 = min(lst)
m2 = max(lst)
dif = m2 - m1
print(dif, end=' ')
if dif == 0:
	print(n * (n - 1) // 2)
else:
	print(lst.count(m1) * lst.count(m2))


n = int(input())
a = list(map(int, input().split()))
maxa = max(a)
mina = min(a)
if maxa == mina:
	r = a.count(mina)
	print(0, r * (r - 1) // 2)
else:
	print(maxa - mina, a.count(mina) * a.count(maxa))


n = int(input())
b = list(map(int, input().split()))
(ma, mi) = (max(b), min(b))
final = str(ma - mi)
(m1, m2) = (b.count(ma), b.count(mi))
if mi < ma:
	print(final, m1 * m2)
else:
	print(final, m2 * (m2 - 1) // 2)


from math import factorial

def calc(n, b):
	c = {}
	(min_f, max_f) = (float('inf'), float('-inf'))
	for flower in b:
		c[flower] = c.get(flower, 0) + 1
		min_f = min(min_f, flower)
		max_f = max(max_f, flower)
	flowers = [key for key in c]
	max_diff = max_f - min_f
	count = 0
	for i in range(len(flowers)):
		if max_diff + flowers[i] in c:
			if max_diff + flowers[i] != flowers[i]:
				count += c[flowers[i]] * c[max_diff + flowers[i]]
			else:
				t = c[flowers[i]]
				count += n * (n - 1) // 2
	print(str(max_diff) + ' ' + str(count))
n = int(input())
b = list(map(int, input().split()))
calc(n, b)


n = int(input())
maxx = minn = 0
for i in map(int, input().split(' ')):
	if maxx == 0 and minn == 0:
		maxx = minn = i
		maxc = minc = 0
	if maxx < i:
		maxx = i
		maxc = 1
	elif maxx == i:
		maxc += 1
	if minn > i:
		minn = i
		minc = 1
	elif minn == i:
		minc += 1
if maxx == minn:
	product = maxc * (minc - 1) // 2
else:
	product = maxc * minc
print(maxx - minn, product)


n = input()
n = int(n)
mx = 0
mn = 0
lst1 = []
lst = list(map(int, input().split()))
a = max(lst)
b = min(lst)
lst1.append(a - b)
for i in range(n):
	if lst[i] == a:
		mx += 1
	else:
		pass
	if lst[i] == b:
		mn += 1
	else:
		pass
lst1.append(mx * mn)
if a == b:
	lst1[1] = int(n * (n - 1) / 2)
for x in lst1:
	print(x, end=' ')
print()


n = int(input())
l = list(map(int, input().split()))
mx = max(l)
mn = min(l)
nmx = l.count(mx)
nmn = l.count(mn)
print(mx - mn, nmx * nmn if mx != mn else nmn * (nmn - 1) // 2)


n = input()
n = int(n)
line = input()
line = line.split()
line = list(map(int, line))
line.sort()
minima = line[0]
maxima = line[-1]
minx = 0
maxx = 0
for item in line:
	if item == maxima:
		maxx += 1
	if item == minima:
		minx += 1
if maxima == minima:
	print(maxima - minima, int(n * (n - 1) / 2))
else:
	print(maxima - minima, minx * maxx)


n = int(input())
b = [int(b) for b in input().split()]
most = max(b)
least = min(b)
if most == least:
	print(0, int(n * (n - 1) / 2))
	exit()
print(most - least, b.count(most) * b.count(least))


n = int(input())
a = list(map(int, input().split()))
maximum = max(a)
minimum = min(a)
a.sort()
c1 = c2 = 0
j = n - 1
while c1 < n and a[c1] == minimum:
	c1 += 1
while j >= 0 and a[j] == maximum:
	j -= 1
	c2 += 1
if maximum == minimum:
	print(0, n * (n - 1) // 2)
else:
	print(maximum - minimum, c1 * c2)


n = int(input())
a = list(map(int, input().split()))
k = max(a) - min(a)
if max(a) == min(a):
	print(0, n * (n - 1) // 2)
else:
	p = a.count(max(a)) * a.count(min(a))
	print(k, p)


n = int(input())
l = list(map(int, input().split()))
l.sort()
max_diff = l[-1] - l[0]
max_beauty = l[-1]
min_beauty = l[0]
c1 = 0
c2 = 0
for i in range(0, n):
	if l[i] == max_beauty:
		c1 += 1
	if l[i] == min_beauty:
		c2 += 1
print(max_diff, end=' ')
if c1 == n and c2 == n:
	print(int(n * (n - 1) / 2))
else:
	print(c1 * c2)


read = lambda : list(map(int, input().split()))
n = read()
A = read()
min = min(A)
max = max(A)
k = max - min
mp = dict()
for i in A:
	if i in mp:
		mp[i] += 1
	else:
		mp[i] = 1
cnt = 0
if len(mp) == 1:
	cnt = (mp[max] - 1) * mp[max] // 2
else:
	for i in A:
		if i - k in mp:
			cnt += mp[i - k]
print(k, end=' ')
print(cnt)


n = int(input())
b = sorted(list(map(int, input().split())))
if len(set(b)) == 1:
	print(0, n * (n - 1) // 2)
else:
	mi = min(b)
	ma = max(b)
	m = b.count(mi)
	k = b.count(ma)
	print(ma - mi, m * k)


import math
n = int(input())
arr = list(map(int, input().split()))
if len(set(arr)) == 1:
	xxx = n * (n - 1) // 2
	print(0, xxx)
	exit()
x = max(arr)
y = min(arr)
diff = x - y
z = arr.count(x)
zz = arr.count(y)
ans = z * zz
print(diff, ans)


n = int(input())
arr = [int(i) for i in input().split()]
arr.sort()
(a, b) = (0, 0)
print(arr[n - 1] - arr[0], end=' ')
t = arr[0]
while arr[a] == t:
	a = a + 1
	if a == n:
		break
if t == arr[n - 1]:
	r = 1
	if n > 2:
		r = n * (n - 1) / 2
	print(int(r))
	exit()
t = arr[n - 1]
while arr[n - b - 1] == t:
	b = b + 1
	if b == n:
		break
r = a * b
print(r)


import fileinput
import math
for line in fileinput.input():
	inp = [int(i) for i in line.split()]
N = len(inp)
if len(set(inp)) == 1:
	print(0, N * (N - 1) // 2)
else:
	minN = inp[0]
	maxN = inp[0]
	for i in inp:
		if i < minN:
			minN = i
		if i > maxN:
			maxN = i
	nMin = 0
	nMax = 0
	for i in inp:
		if i == minN:
			nMin = nMin + 1
		if i == maxN:
			nMax = nMax + 1
	print(maxN - minN, nMin * nMax)


from collections import Counter
n = int(input())
ls = list(map(int, input().split()))
d = dict(Counter(ls))
if len(set(ls)) == 1:
	print(0, d[ls[0]] * (d[ls[0]] - 1) // 2)
else:
	print(max(ls) - min(ls), d[max(ls)] * d[min(ls)])


l = int(input())
ls = list(map(int, input().split()))
x = ls[0]
xx = 0
y = ls[0]
yy = 0
for i in ls:
	if i < x:
		x = i
		xx = 0
	elif i > y:
		y = i
		yy = 0
	if i == x:
		xx += 1
	if i == y:
		yy += 1
if x == y:
	print(y - x, int(xx * (xx - 1) / 2))
else:
	print(y - x, xx * yy)


from collections import Counter
n = int(input())
arr = [int(x) for x in input().split()]
mx = max(arr)
mn = min(arr)
c = Counter(arr)
if mx == mn:
	print(mx - mn, n * (n - 1) // 2)
else:
	print(mx - mn, c[mx] * c[mn])


n = int(input())
a = list(map(int, input().split()))
ma = max(a)
mi = min(a)
c = a.count(ma)
d = a.count(mi)
if ma == mi:
	if c == 2:
		print(ma - mi, '1')
	else:
		print(ma - mi, c * (c - 1) // 2)
else:
	print(ma - mi, c * d)


n = int(input())
m = 0
t = 0
a = [int(n) for n in input().split(' ')]
if min(a) == max(a):
	t = int(len(a) * (len(a) - 1) / 2)
else:
	t = a.count(min(a)) * a.count(max(a))
m = max(a) - min(a)
print(m, t)


n = int(input())
m = [int(i) for i in input().split()]
diff = max(m) - min(m)
if diff == 0:
	ways = n * (n - 1) // 2
else:
	ways = m.count(max(m)) * m.count(min(m))
print(diff, ways)


n = int(input())
arr = [int(x) for x in input().split()]
mx = max(arr)
mx_count = 0
mn_count = 0
mn = min(arr)
for x in arr:
	if x == mx:
		mx_count += 1
	if x == mn:
		mn_count += 1
if mx == mn:
	print(0, n * (n - 1) // 2)
else:
	print(mx - mn, mx_count * mn_count)


t = int(input())
l = list(map(int, input().split()))
maxx = max(l)
minn = min(l)
maxi = 0
mini = 0
for i in l:
	if i == maxx:
		maxi += 1
	if i == minn:
		mini += 1
if maxx == minn:
	cc = int(t * (t - 1) / 2)
else:
	cc = maxi * mini
print(maxx - minn, cc)


n = int(input())
l = list(map(int, input().split()))
k = min(l)
m = max(l)
for i in range(n):
	if l[i] == k:
		l[i] = 0
	elif l[i] == m:
		l[i] = -1
if k == m:
	print(0, n * (n - 1) // 2)
else:
	print(m - k, l.count(-1) * l.count(0))


n = int(input())
a = list(map(int, input().split()))
(MIN, MAX) = (min(a), max(a))
print(MAX - MIN, end=' ')
print(n * (n - 1) // 2 if MAX == MIN else a.count(MAX) * a.count(MIN))


n = int(input())
b = [int(t) for t in input().split()]
minb = b[0]
mincount = 1
maxb = b[0]
maxcount = 1
for i in b[1:]:
	if i < minb:
		minb = i
		mincount = 1
	elif i > maxb:
		maxb = i
		maxcount = 1
	else:
		if i == minb:
			mincount += 1
		if i == maxb:
			maxcount += 1
possibilities = mincount * maxcount
if maxb == minb:
	possibilities = maxcount * (maxcount - 1) // 2
print(maxb - minb, possibilities)


n = int(input())
import math
x = [int(x) for x in input().split()]
x.sort()
d = x[-1] - x[0]
p = x.count(x[0]) * x.count(x[-1])
if x[0] == x[-1]:
	p = n * (n - 1) // 2
print(d, p)


from sys import stdin
inFile = stdin
tokens = []
tokens_next = 0

def next_str():
	global tokens, tokens_next
	while tokens_next >= len(tokens):
		tokens = inFile.readline().split()
		tokens_next = 0
	tokens_next += 1
	return tokens[tokens_next - 1]

def nextInt():
	return int(next_str())
n = nextInt()
a = sorted([nextInt() for i in range(n)])
l = 0
r = 1
res = 0
while l < len(a):
	r = max(r, l + 1)
	while r < len(a) and a[r] - a[l] < a[-1] - a[0]:
		r += 1
	res += len(range(r, len(a)))
	l += 1
print(a[-1] - a[0], res)


n = int(input())
B = [int(x) for x in input().split()]
minCount = 0
maxCount = 0
minVal = min(B)
maxVal = max(B)
for i in B:
	if i == minVal:
		minCount += 1
	if i == maxVal:
		maxCount += 1
print(str(maxVal - minVal), end=' ')
if minVal == maxVal:
	print(str(minCount * (minCount - 1) // 2))
else:
	print(str(minCount * maxCount))


n = int(input())
l = list(map(int, input().split()))
l.sort()
a = l[0]
b = l[n - 1]
x = l.count(a)
y = l.count(b)
if a == b:
	print(b - a, end=' ')
	print(x * (x - 1) // 2)
else:
	print(b - a, end=' ')
	print(x * y)


def ii():
	return int(input())

def ss():
	return [x for x in input()]

def si():
	return [int(x) for x in input().split()]

def mi():
	return map(int, input().split())
a = ii()
s = si()
mn = min(s)
mx = max(s)
if mn != mx:
	print(mx - mn, s.count(mx) * s.count(mn))
else:
	print(0, a * (a - 1) // 2)


from collections import defaultdict, Counter

def diff_ways(flowers):
	min_val = min(flowers)
	max_val = max(flowers)
	c = Counter(flowers)
	if min_val == max_val:
		ways = int(n * (n - 1) / 2)
	else:
		ways = c[min_val] * c[max_val]
	return (max_val - min_val, ways)
n = int(input())
flowers = list(map(int, input().split()))
(diff, ways) = diff_ways(flowers)
print(f'{diff} {ways}')


n = int(input())
ar = list(map(int, input().split()))
ar.sort()
mn = ar[0]
mx = ar[n - 1]
print(mx - mn, end=' ')
p = ar.count(mn)
q = ar.count(mx)
if mx == mn:
	print(int(p * (p - 1) / 2))
else:
	print(p * q)


input()
l = sorted(map(int, input().split()))
a = l[0]
b = l[-1]
c = len(l)
print(b - a, l.count(a) * l.count(b) if a != b else c * (c - 1) // 2)


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
l.sort()
min = l[0]
max = l[n - 1]
if min == max:
	ans1 = 0
	ans2 = n * (n - 1) // 2
else:
	a = Counter(l)
	ans1 = max - min
	ans2 = a[min] * a[max]
print(ans1, ans2)


n = int(input())
l = list(map(int, input().split()))
max1 = max(l)
min1 = min(l)
ans = max1 - min1
print(ans, end=' ')
x = l.count(max1)
y = l.count(min1)
if x == n:
	print(n * (n - 1) // 2)
else:
	print(x * y)


n = int(input())
arr = input().split(' ')
arr = [int(i) for i in arr]
mx = 0
mn = 1000000001
for i in arr:
	if i > mx:
		mx = i
	if i < mn:
		mn = i
cnt_min = 0
cnt_max = 0
for i in arr:
	if i == mn:
		cnt_min += 1
	elif i == mx:
		cnt_max += 1
diff = mx - mn
num = cnt_min * cnt_max
if mx == mn:
	num = int(cnt_min * (cnt_min - 1) / 2)
print(diff, num)


n = int(input())
L = [int(i) for i in input().split()]
(Max, Min) = (max(L), min(L))
Maxc = L.count(Max)
Minc = L.count(Min)
if Max == Min:
	print(Max - Min, Maxc * (Minc - 1) // 2)
else:
	print(Max - Min, Maxc * Minc)


from collections import defaultdict
n = int(input())
li = list(map(int, input().split()))
f = defaultdict(int)
(mini, maxi) = (1000000000.0 + 10, 0)
for i in li:
	f[i] += 1
	mini = min(mini, i)
	maxi = max(maxi, i)
if mini == maxi:
	print(0, f[mini] * (f[mini] - 1) // 2)
else:
	print(maxi - mini, f[maxi] * f[mini])


def kk():
	n = int(input())
	liss = list(map(int, input().split()))
	m = max(liss)
	p = min(liss)
	nm = liss.count(m)
	np = liss.count(p)
	if m == p:
		print(0, int(n * (n - 1) / 2))
		return
	print(m - p, nm * np)
	return
kk()


n = int(input())
x = [int(x) for x in input().split()]
x.sort()
mini = x[0]
maxi = x[n - 1]
a = 0
b = 0
if maxi == mini:
	print(0, n * (n - 1) // 2)
else:
	for i in x:
		if i == mini:
			a += 1
		else:
			break
	for i in range(n - 1, -1, -1):
		if x[i] == maxi:
			b += 1
		else:
			break
	print(maxi - mini, a * b)


n = int(input())
l = sorted(list(map(int, input().split())))
ans1 = l[-1] - l[0]
if l[-1] == l[0]:
	ans2 = 0
	for f in range(n):
		ans2 += f
	print(ans1, ans2)
else:
	lmax = 1
	lmin = 1
	for f in range(n - 1):
		if l[f] == l[f + 1]:
			lmin += 1
		else:
			break
	for f in range(n - 1, -1, -1):
		if l[f] == l[f - 1]:
			lmax += 1
		else:
			break
	print(ans1, lmax * lmin)


n = int(input())
l = list(map(int, input().split()))
l.sort()
minimum = l[0]
maximum = l[-1]
if l.count(minimum) == n:
	print(0, n * (n - 1) // 2)
else:
	print(maximum - minimum, l.count(minimum) * l.count(maximum))


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
n = int(z())
l = szzz()
x1 = l[0]
x2 = l[-1]
t1 = l.count(x1)
t2 = l.count(x2)
t = t1 * t2
if x1 == x2:
	t = int(n * (n - 1) / 2)
print(x2 - x1, t)


import bisect
n = int(input())
arr = [int(i) for i in input().split(' ')]
arr.sort()
if arr[0] == arr[-1]:
	print(0, n * (n - 1) // 2)
	exit()
max_diff = arr[-1] - arr[0]
count = bisect.bisect_right(arr, arr[0]) * (n - bisect.bisect_left(arr, arr[-1]))
print(max_diff, count)


n = int(input())
flowers = [int(x) for x in input().split(' ')]
flowers = sorted(flowers)
if flowers[0] == flowers[-1]:
	print('{} {}'.format(0, n * (n - 1) // 2))
else:
	minimals = 0
	index_start = 0
	while True:
		if flowers[0] == flowers[index_start]:
			minimals += 1
			index_start += 1
		else:
			break
	maximals = 0
	index_end = n - 1
	while True:
		if flowers[-1] == flowers[index_end]:
			maximals += 1
			index_end -= 1
		else:
			break
	print('{} {}'.format(flowers[-1] - flowers[0], maximals * minimals))


n = int(input())
arr = list(map(int, input().split()))
(mx, mn, diff) = (max(arr), min(arr), max(arr) - min(arr))
print(diff, n * (n - 1) // 2 if mx == mn else arr.count(mx) * arr.count(mn))


n = input()
b = list(map(int, input().split()))
max_b = max(b)
min_b = min(b)
if min_b != max_b:
	print(max_b - min_b, b.count(min_b) * b.count(max_b))
else:
	cnt = b.count(min_b)
	print(0, cnt * (cnt - 1) // 2)


n = int(input())
a = list(map(int, input().split()))
mn = a[0]
mx = a[0]
for i in range(1, n):
	if a[i] > mx:
		mx = a[i]
	if a[i] < mn:
		mn = a[i]
if mn == mx:
	print(0, n * (n - 1) // 2)
else:
	c1 = 0
	c2 = 0
	for i in range(n):
		if mn == a[i]:
			c1 = c1 + 1
		if mx == a[i]:
			c2 = c2 + 1
	print(mx - mn, c1 * c2)


n = int(input())
l = [int(x) for x in input().split()]
a = min(l)
b = max(l)
count_a = l.count(a)
count_b = l.count(b)
if a == b:
	print(0, (count_a - 1) * count_a // 2)
else:
	print(b - a, count_a * count_b)


n = int(input())
b = [int(i) for i in input().split(' ')]
mn = min(b)
mx = max(b)
cmn = b.count(mn)
cmx = b.count(mx)
d = mx - mn
print(d, end=' ')
print(int(n * (n - 1) / 2) if mx == mn else cmn * cmx)


n = int(input())
xs = sorted(map(int, input().split()))
x1 = xs[0]
k1 = 0
for x in xs:
	if x == x1:
		k1 += 1
	else:
		break
x2 = xs[-1]
k2 = 0
for x in reversed(xs):
	if x == x2:
		k2 += 1
	else:
		break
d = x2 - x1
w = k1 * k2 if x1 != x2 else k1 * (k1 - 1) // 2
print(d, w)


import functools

def max(a, b):
	if a > b:
		return a
	return b

def min(a, b):
	if a < b:
		return a
	return b
n = int(input())
b = list(map(int, input().split()))
maxf = functools.reduce(lambda x, y: max(x, y), b)
minf = functools.reduce(lambda x, y: min(x, y), b)
if maxf == minf:
	v = b.count(maxf)
	print(0, int(v * (v - 1) / 2), end=' ')
else:
	nomax = b.count(maxf)
	nomin = b.count(minf)
	print(maxf - minf, nomax * nomin, end=' ')


n = int(input())
data = list(map(int, input().split()))
maxx = max(data)
minn = min(data)
count_min = 0
count_max = 0
if minn == maxx:
	result = int(len(data) * (len(data) - 1) / 2)
	print('{} {}'.format(0, result))
else:
	for d in data:
		if d == maxx:
			count_max += 1
		elif d == minn:
			count_min += 1
	diff = maxx - minn
	result = count_max * count_min
	print('{} {}'.format(diff, result))


from sys import stdin
n = int(stdin.readline())
a = list(map(int, stdin.readline().split(' ')))
a.sort()
l = 0
r = 1
res = 0
while l < len(a):
	r = max(r, l + 1)
	while r < len(a) and a[r] - a[l] < a[-1] - a[0]:
		r += 1
	res += len(range(r, len(a)))
	l += 1
print(a[-1] - a[0], res)


from math import *

def fact(n):
	if n == 0:
		return 1
	else:
		return n * fact(n - 1)
n = int(input())
flores = input().split(' ')
c_min = 1
c_max = 1
v_min = int(flores[0])
v_max = int(flores[0])
for i in range(1, len(flores)):
	if int(flores[i]) < v_min:
		v_min = int(flores[i])
		c_min = 1
	elif int(flores[i]) == v_min:
		c_min += 1
	if int(flores[i]) > v_max:
		v_max = int(flores[i])
		c_max = 1
	elif int(flores[i]) == v_max:
		c_max += 1
if c_max == len(flores):
	print(0, int(len(flores) * (len(flores) - 1) / 2))
else:
	print(v_max - v_min, c_min * c_max)


n = int(input())
a = list(map(int, input().split()))
a.sort()
l = a.count(a[0])
h = a.count(a[n - 1])
print(a[n - 1] - a[0], end=' ')
if a[0] == a[n - 1]:
	print(n * (n - 1) // 2)
else:
	print(h * l)


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
x = min(a)
y = max(a)
ans = y - x
x = a.count(x)
y = a.count(y)
if ans == 0:
	print(*(ans, x * (x - 1) // 2))
else:
	print(*(ans, x * y))


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
mi = a[0]
ma = a[n - 1]
cmin = 0
cmax = 0
if mi == ma:
	print(str(0) + ' ' + str(int(n * (n - 1) / 2)))
	exit()
for i in range(n):
	if a[i] == mi:
		cmin += 1
	if a[i] == ma:
		cmax += 1
print(str(ma - mi) + ' ' + str(min(cmin, cmax) * max(cmin, cmax)))


a = int(input())
b = input().split()
all_flowers = []
for el in b:
	el = int(el)
	all_flowers.append(el)
all_flowers = sorted(all_flowers)
max_ = all_flowers[-1]
min_ = all_flowers[0]
difference = max(all_flowers) - min(all_flowers)
massiv_of_minimum = []
massiv_of_maximum = []
for el in all_flowers:
	if el == min_:
		massiv_of_minimum.append(el)
	if el == max_:
		massiv_of_maximum.append(el)
if sum(massiv_of_minimum) != sum(massiv_of_maximum):
	counter = len(massiv_of_maximum) * len(massiv_of_minimum)
else:
	summ = 0
	len_massiv = len(all_flowers)
	for el in all_flowers:
		summ += 1 * len_massiv - 1
		len_massiv -= 1
	counter = summ
print(difference, counter)


n = int(input())
flowers = [int(i) for i in input().split()]
flowers.sort()
max = flowers[n - 1] - flowers[0]
res = '' + str(max) + ' '
low = 1
high = 1
i = 1
j = n - 2
if max > 0:
	while flowers[i] == flowers[0]:
		low += 1
		i += 1
		if i == n:
			break
	while flowers[j] == flowers[n - 1]:
		high += 1
		j -= 1
		if j == -1:
			break
	res += str(low * high)
else:
	aux = n - 1
	acum = 0
	while aux > 0:
		acum += aux
		aux -= 1
	res += str(acum)
print(res)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
max_diff = arr[-1] - arr[0]
min = arr[0]
max = arr[-1]
min_c = 0
max_c = 0
for i in arr:
	if i == min:
		min_c += 1
for i in arr:
	if i == max:
		max_c += 1
if len(set(arr)) == 1:
	combinations = n * (n - 1) // 2
else:
	combinations = min_c * max_c
ans = [max_diff, combinations]
for i in ans:
	print(i, end=' ')
print('')


import math
n = int(input())
a = list(map(int, input().split()))
a.sort()
diff = max(a) - min(a)
c = 0
if a[0] == a[n - 1]:
	print(str(diff) + ' ' + str(int(n * (n - 1) / 2)))
else:
	print(str(diff) + ' ' + str(a.count(max(a)) * a.count(min(a))))


n = int(input())
l = list(map(int, input().split()))
l.sort()
x = l.count(l[0])
y = l.count(l[n - 1])
if l[n - 1] - l[0] == 0:
	print(0, int(x * (x - 1) / 2), sep=' ')
else:
	print(l[n - 1] - l[0], x * y, sep=' ')


n = int(input())
a = list(map(int, input().split()))
m1 = max(a)
m2 = min(a)
if m1 == m2:
	k = a.count(m1)
	print(m1 - m2, k * (k - 1) // 2)
else:
	c1 = a.count(m1)
	c2 = a.count(m2)
	print(m1 - m2, c1 * c2)


n = int(input())
b = list((int(i) for i in input().split()))
b.sort()
max = b[n - 1] - b[0]
c1 = 0
c2 = 0
i = 0
while b[i] == b[0] and i < n - 1:
	c1 += 1
	i += 1
i = n - 1
while b[i] == b[n - 1] and i > 0:
	c2 += 1
	i -= 1
ways = c1 * c2
if b[0] == b[n - 1]:
	ways = int(n * (n - 1) / 2)
print(max, ways)


n = int(input())
a = list(map(int, input().split()))
a.sort()
min_kol = 0
max_kol = 0
for i in range(len(a)):
	if a[i] == a[0]:
		min_kol += 1
	if a[i] == a[len(a) - 1]:
		max_kol += 1
print(a[len(a) - 1] - a[0], end=' ')
if a[0] == a[len(a) - 1]:
	print(n * (n - 1) // 2)
else:
	print(min_kol * max_kol)


n = int(input())
b = list(map(int, input().strip().split()))[:n]
b.sort()
max_count = 0
min_count = 0
max_num = b[n - 1]
min_num = b[0]
for i in range(n):
	if b[i] == min_num:
		min_count += 1
	if b[i] == max_num:
		max_count += 1
pair = max_num - min_num
if min_num == max_num:
	ways = int(n * (n - 1) / 2)
else:
	ways = min_count * max_count
print('{} {}'.format(pair, ways))


n = int(input())
arr = [int(i) for i in input().split()]
max_ = arr[0]
min_ = arr[0]
count_max = 0
count_min = 0
for a in arr:
	if a > max_:
		max_ = a
		count_max = 1
	elif a == max_:
		count_max += 1
	if a < min_:
		min_ = a
		count_min = 1
	elif a == min_:
		count_min += 1
if max_ == min_:
	print(0, n * (n - 1) // 2)
else:
	print(max_ - min_, count_max * count_min)


n = int(input())
l = [int(x) for x in input().split()]
l.sort()
ma = l[n - 1] - l[0]
if ma != 0:
	shu = l.count(l[n - 1]) * l.count(l[0])
else:
	shu = n * (n - 1) // 2
print(ma, shu)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
a = arr.count(arr[0])
b = arr.count(arr[n - 1])
if arr[0] == arr[n - 1]:
	print(0, a * (b - 1) // 2)
	exit(0)
print(arr[n - 1] - arr[0], b * a)


from bisect import bisect_right
from bisect import bisect_left
n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[0] == a[-1]:
	print(0, n * (n - 1) // 2)
else:
	print(a[-1] - a[0], (bisect_right(a, a[0]) - bisect_left(a, a[0])) * (bisect_right(a, a[-1]) - bisect_left(a, a[-1])))


n = int(input())
l = list(map(int, input().split()))
hi = max(l)
lo = min(l)
if hi - lo == 0:
	print('0 ' + str(int(n * (n - 1) / 2)))
else:
	chi = 0
	clo = 0
	for i in l:
		if i == hi:
			chi += 1
		if i == lo:
			clo += 1
	print(str(hi - lo) + ' ' + str(chi * clo))


from sys import stdin
import math
inp = lambda : stdin.readline().strip()

def nCr(n, r):
	if r > n - r:
		r = n - r
	ans = 1
	for i in range(1, r + 1):
		ans *= n - r + i
		ans //= i
	return ans
n = int(inp())
a = [int(x) for x in inp().split()]
low = min(a)
high = max(a)
cLow = 0
cHigh = 0
for i in a:
	if i == low:
		cLow += 1
	elif i == high:
		cHigh += 1
if low == high:
	print(high - low, int(nCr(cLow, 2)))
else:
	print(high - low, cLow * cHigh)


n = int(input())
b = list(map(int, input().split()))
p = min(b)
q = max(b)
countp = 0
countq = 0
for i in b:
	if i == p:
		countp = countp + 1
	if i == q:
		countq = countq + 1
if p == q:
	print(0, countp * (countq - 1) // 2)
else:
	print(q - p, countp * countq)


n = int(input())
a = [int(i) for i in input().split()]
a = sorted(a)
if a[-1] - a[0] == 0:
	print(a[-1] - a[0], int(n * (n - 1) / 2))
else:
	print(a[-1] - a[0], a.count(a[0]) * a.count(a[-1]))


n = int(input())
b = sorted(list(map(int, input().split())))
if b[n - 1] == b[0]:
	print(0, n * (n - 1) // 2)
else:
	(p1, p2, l, r) = (1, 1, 0, n - 1)
	while b[l] == b[l + 1]:
		(p1, l) = (p1 + 1, l + 1)
	while b[r] == b[r - 1]:
		(p2, r) = (p2 + 1, r - 1)
	print(b[n - 1] - b[0], p1 * p2)


def P(n):
	res = 1
	for i in range(1, n + 1):
		res *= i
	return res

def A(n, k):
	res = 0
	return P(n) / P(n - k)

def C(n, k):
	return int(P(n) / (P(n - k) * P(k)))
a = int(input())
b = [int(i) for i in input().split()]
b.sort()
res = b[-1] - b[0]
d = 0
e = 0
if b[-1] == b[0]:
	resb = a * (a - 1) // 2
else:
	f = b[-1]
	j = b[0]
	for i in b:
		if i == f:
			d += 1
		if i == j:
			e += 1
	resb = d * e
print(res, resb)


length = int(input())
flower_list = list(map(int, input().split(' ')))
max_value = max(flower_list)
min_value = min(flower_list)
if max_value == min_value:
	print(max_value - min_value, length * (length - 1) // 2)
else:
	print(max_value - min_value, flower_list.count(max_value) * flower_list.count(min_value))


inputsize = int(input())
ara = list(map(int, input().split()))
counta = 0
ara.sort()
difference = ara[inputsize - 1] - ara[0]
if not difference == 0:
	counta = ara.count(ara[-1]) * ara.count(ara[0])
else:
	counta = inputsize * (inputsize - 1) // 2
print(difference, end=' ')
print(counta)


N = int(input())
A = list(map(int, input().split()))
A.sort()
left = 0
right = N - 1
diff = A[right] - A[left]
ans1 = ans2 = 0
if A[0] == A[-1]:
	ans = N * (N - 1) // 2
	print(diff, ans)
else:
	for i in range(N - 1):
		if A[i] != A[left]:
			break
		else:
			ans1 += 1
	for i in range(N - 1, 0, -1):
		if A[i] != A[right]:
			break
		else:
			ans2 += 1
	print(diff, ans1 * ans2)


n = int(input())
b = list(map(int, input().split()))
b.sort()
c1 = b.count(b[0])
c2 = b.count(b[-1])
if c1 == n or c2 == n:
	res = n * (n - 1) // 2
else:
	res = c1 * c2
print(b[-1] - b[0], res, sep=' ')


n = int(input())
L = list(map(int, input().split()))
L.sort()
i = n - 1
while i >= 0 and L[i] == L[n - 1]:
	i -= 1
b = n - i - 1
i = 0
while i < n and L[i] == L[0]:
	i += 1
a = i
if L[0] == L[n - 1]:
	print(0, n * (n - 1) // 2)
else:
	print(L[n - 1] - L[0], a * b)


import math as m
n = eval(input())
datas = list(map(int, input().split()))
max_of_data = -1
max_count = 0
min_of_data = 1000000001
min_count = 0
for i in datas:
	if i < min_of_data:
		min_of_data = i
		min_count = 1
	elif i == min_of_data:
		min_count += 1
	if i > max_of_data:
		max_of_data = i
		max_count = 1
	elif i == max_of_data:
		max_count += 1
max_diff = max_of_data - min_of_data
max_diff_count = max_count * min_count
if max_diff == 0:
	i = max_count
	max_diff_count = n * (n - 1) // 2
print(max_diff, max_diff_count)


from sys import stdin, stderr
from collections import Counter

def readInts():
	return map(int, stdin.readline().strip().split())

def print_err(*args, **kwargs):
	print(*args, file=stderr, **kwargs)

def solve(vs):
	min_v = min(vs)
	max_v = max(vs)
	f = Counter(vs)
	if min_v == max_v:
		c = f[min_v]
		return (0, c * (c - 1) // 2)
	return (max_v - min_v, f[max_v] * f[min_v])

def run():
	(n,) = readInts()
	vs = list(readInts())
	print(' '.join(map(str, solve(vs))))
run()


def main():
	(n,) = read()
	a = read()
	mn = 10 ** 9 + 1
	mncount = 0
	mx = 0
	mxcount = 0
	for i in range(n):
		if a[i] < mn:
			mn = a[i]
			mncount = 1
		elif a[i] == mn:
			mncount += 1
		if a[i] > mx:
			mx = a[i]
			mxcount = 1
		elif a[i] == mx:
			mxcount += 1
	if mx != mn:
		print(mx - mn, mncount * mxcount)
	else:
		print(0, n * (n - 1) // 2)

def read(mode=2):
	inputs = input().strip()
	if mode == 0:
		return inputs
	if mode == 1:
		return inputs.split()
	if mode == 2:
		return list(map(int, inputs.split()))

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='')
write(main())


import operator as op
from functools import reduce

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom
n = int(input())
b = [int(i) for i in input().split()]
max_b = max(b)
min_b = min(b)
bd = max_b - min_b
pairs = b.count(max_b) * b.count(min_b) if bd != 0 else int(ncr(n, 2))
print(bd, pairs)


input()
a = [int(x) for x in input().split()]
(max_a, min_a) = (max(a), min(a))
(max_count, min_count) = (a.count(max_a), a.count(min_a))
if max_a != min_a:
	print(max_a - min_a, max_count * min_count)
else:
	print(0, max_count * (max_count - 1) // 2)


n = int(input())
arr = [int(x) for x in input().split(' ')]
bada = max(arr)
chota = min(arr)
a = arr.count(bada)
b = arr.count(chota)
if bada == chota:
	print(bada - chota, a * (a - 1) // 2)
else:
	print(bada - chota, a * b)


from collections import Counter
input()
c = Counter((int(i) for i in input().split()))
(n, m) = (max(c), min(c))
if n == m:
	print(0, c[n] * (c[n] - 1) // 2)
else:
	print(n - m, c[n] * c[m])


import math
t = int(input())
l = list(map(int, input().split()))
l = sorted(l)
m = l[t - 1] - l[0]
if m == 0:
	count = t * (t - 1) // 2
else:
	count = l.count(l[t - 1]) * l.count(l[0])
print(m, end=' ')
print(count)


def n_choose_k(n, k):
	k = min(k, n - k)
	ans = 1
	for i in range(k):
		ans = ans * (n - i) / (i + 1)
	return ans
n = int(input())
arr = [int(x) for x in input().split()]
(mi, mx, mic, mxc) = (-1, -1, 0, 0)
for x in arr:
	mi = x if mi == -1 else min(mi, x)
	mx = x if mx == -1 else max(mx, x)
for x in arr:
	if x == mi:
		mic += 1
	if x == mx:
		mxc += 1
ans = int(mic * mxc) if mi != mx else int(n_choose_k(mic, 2))
print(f'{abs(mx - mi)} {ans}')


n = int(input())
bLine = input().split()
smallest = int(bLine[0])
smallestCounter = 0
largest = int(bLine[0])
largestCounter = 0
for i in range(n):
	bLine[i] = int(bLine[i])
	if bLine[i] > largest:
		largest = bLine[i]
		largestCounter = 1
	elif bLine[i] == largest:
		largestCounter += 1
	if bLine[i] < smallest:
		smallest = bLine[i]
		smallestCounter = 1
	elif bLine[i] == smallest:
		smallestCounter += 1
if smallest == largest:
	sum = 0
	for i in range(0, smallestCounter):
		sum += i
	print(0, sum)
else:
	print(largest - smallest, largestCounter * smallestCounter)


import math
n = int(input())
a = list(map(int, input().split()))
m1 = max(a)
m2 = min(a)
m3 = a.count(m1)
m4 = a.count(m2)
if m1 - m2 == 0:
	print(0, m3 * (m3 - 1) // 2)
else:
	print(m1 - m2, m3 * m4)


import sys
from collections import Counter
input = lambda : sys.stdin.readline().strip('\r\n')
n = int(input())
b = list(map(int, input().split()))
c = Counter(b)
first = min(b)
last = max(b)
if first != last:
	flowers = c[first] * c[last]
	print(last - first, flowers)
else:
	print(0, n * (n - 1) // 2)


from math import factorial
N = int(input())
l = [int(i) for i in input().split()]
(Min, Max) = (min(l), max(l))
if Min != Max:
	min_count = l.count(Min)
	max_count = l.count(Max)
	print(f'{Max - Min} {min_count * max_count}')
else:
	print(f'{0} {N * (N - 1) // 2}')


n = int(input())
b = list(map(int, input().split()))
if max(b) == min(b):
	print(max(b) - min(b), b.count(max(b)) ** 2 // 2 - b.count(max(b)) // 2)
else:
	print(max(b) - min(b), b.count(max(b)) * b.count(min(b)))


n = int(input())
flowers = [int(x) for x in input().split()]
mxb = max(flowers)
minb = min(flowers)
d = dict()
d[mxb] = 0
d[minb] = 0
for f in flowers:
	if f == mxb:
		d[mxb] += 1
	elif f == minb:
		d[minb] += 1
ways = d[mxb] * d[minb]
if mxb == minb:
	ways = n * (n - 1) // 2
print(mxb - minb, ways)


n = int(input())
line = str(input()).split()
line = [int(it) for it in line]
max_c = 0
min_c = 0
max_v = max(line)
min_v = min(line)
for i in range(n):
	if line[i] == max_v:
		max_c += 1
	if line[i] == min_v:
		min_c += 1
if max_v > min_v:
	print(str(max_v - min_v) + ' ' + str(max_c * min_c))
else:
	print(str(max_v - min_v) + ' ' + str(int(max_c * (min_c - 1) / 2)))


(a, b) = (int(input()), list(map(int, input().split())))
print(max(b) - min(b), b.count(max(b)) * b.count(min(b)) if max(b) - min(b) != 0 else a * (a - 1) // 2)


p = int(input())
l = []
l = [int(x) for x in input().split()]
max = l[0]
min = l[0]
m = 0
n = 0
for x in l:
	if x > max:
		max = x
		m = 1
	elif x == max:
		m = m + 1
	if x < min:
		min = x
		n = 1
	elif x == min:
		n = n + 1
if max == min:
	p = int(n / 2)
	if n % 2 == 1:
		m = n * p
	else:
		m = (n - 1) * p
else:
	m = m * n
max = max - min
print(max, ' ', m)


n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = l[n - 1] - l[0]
mn = l.count(l[0])
mx = l.count(l[n - 1])
if ans == 0:
	print(ans, n * (n - 1) // 2)
else:
	print(ans, mn * mx)


import math
a = int(input())
inpu = input().split()
mini = 99999999999999
maxi = -1
data = []
for x in inpu:
	m = int(x)
	if m > maxi:
		maxi = m
	if mini > m:
		mini = m
	data.append(m)
val = data.count(mini) * data.count(maxi)
if mini == maxi:
	ss = data.count(mini)
	val = int(ss * (ss - 1) / 2)
print(maxi - mini, val)


import sys
n = int(input())
b = list((int(temp) for temp in input().split(' ')))
x = max(b)
y = min(b)
if x == y:
	numWays = int(b.count(x) * (b.count(x) - 1) / 2)
else:
	numWays = b.count(x) * b.count(y)
print(x - y, numWays)


n = int(input())
l = sorted(map(int, input().split()))
ans = l[-1] - l[0]
if ans == 0:
	print(ans, (n - 1) * n // 2)
else:
	id = 1
	i = n - 2
	while 1:
		if l[i] == l[-1]:
			id += 1
		else:
			break
		i -= 1
	id2 = 1
	i = 1
	while 1:
		if l[i] == l[0]:
			id2 += 1
		else:
			break
		i += 1
	print(ans, id * id2)


n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
beauty = arr[-1] - arr[0]
(c1, c2) = (0, 0)
for i in arr:
	if i == arr[0]:
		c1 += 1
	elif i == arr[-1]:
		c2 += 1
if arr[0] == arr[-1]:
	print(beauty, c1 * (c1 - 1) // 2)
else:
	print(beauty, c1 * c2)


a = int(input())
b = sorted(list(map(int, input().split())))
b_max = max(b)
b_min = min(b)
print(b_max - b_min, end=' ')
if b_max != b_min:
	print(b.count(b_max) * b.count(b_min))
else:
	print(b.count(b_max) * (b.count(b_max) - 1) // 2)


n = int(input())
lst = list(map(int, input().split()))
lst.sort()
a = lst[0]
b = lst[n - 1]
if a == b:
	print(b - a, n * (n - 1) // 2)
else:
	print(b - a, lst.count(a) * lst.count(b))


n = int(input())
a = list(map(int, input().split()))
(mx, mn) = (max(a), min(a))
if mx != mn:
	c = a.count(mx) * a.count(mn)
else:
	c = n * (n - 1) // 2
print(mx - mn, c, sep=' ')


flowers = int(input())
beauty = list(map(int, input().strip().split()))
ugliest = min(beauty)
prettiest = max(beauty)
uglyFlowers = beauty.count(ugliest)
prettyFlowers = beauty.count(prettiest)
if ugliest == prettiest:
	print(prettiest - ugliest, flowers * (flowers - 1) // 2)
else:
	print(prettiest - ugliest, uglyFlowers * prettyFlowers)


t = int(input())
a = [int(j) for j in input().split()]
mi = min(a)
ma = max(a)
micount = a.count(mi)
macount = a.count(ma)
if mi == ma:
	print(0, int(t * (t - 1) / 2))
else:
	diff = ma - mi
	count = micount * macount
	print(diff, count)


n = int(input())
beauties = list(map(int, input().split()))
(min_beauty, max_beauty) = (min(beauties), max(beauties))
if min_beauty == max_beauty:
	print(0, n * (n - 1) // 2)
else:
	print(max_beauty - min_beauty, beauties.count(min_beauty) * beauties.count(max_beauty))


n = int(input())
fl = [int(x) for x in input().split()]
fl.sort()
n_start = 1
n_end = 1
while n_start < n and fl[0] == fl[n_start]:
	n_start += 1
while n_end < n - 2 and fl[-1] == fl[-1 - n_end]:
	n_end += 1
if n_start == n:
	print(0, n * (n - 1) // 2)
else:
	print(fl[-1] - fl[0], n_start * n_end)


n = int(input())
l = list(map(int, input().split()))
l.sort()
maxi = l[n - 1] - l[0]
a = l.count(l[0])
b = l.count(l[n - 1])
if l[0] == l[n - 1]:
	print(maxi, n * (n - 1) // 2)
else:
	print(maxi, a * b)


n = int(input())
arr = sorted(list(map(int, input().split())))
diff = arr[n - 1] - arr[0]
a = b = 0
for i in range(n):
	if arr[i] == arr[0]:
		a += 1
	else:
		break
for i in range(n - 1, -1, -1):
	if arr[i] == arr[n - 1]:
		b += 1
	else:
		break
ans = b * a
if arr[0] == arr[-1]:
	ans = n * (n - 1) // 2
print(diff, ans)


n = int(input())
l1 = list(map(int, input().split()))
l1.sort()
c = len(l1)
small = l1[0]
large = l1[n - 1]
sum1 = l1.count(small)
sum2 = l1.count(large)
if small == large:
	sumx = sum1 // 2
	sumy = sum1 // 2
	print(large - small, int(c * (c - 1) / 2), end=' ')
else:
	print(large - small, sum1 * sum2, end=' ')


n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
mini = l[0]
maxi = l[-1]
m = l.count(mini)
M = l.count(maxi)
if maxi != mini:
	print(str(maxi - mini) + ' ' + str(m * M))
else:
	print(str(0) + ' ' + str(m * (m - 1) // 2))


a = int(input())
l = list(map(int, input().split()))
m = max(l)
mi = min(l)
print(m - mi, end=' ')
print(a * (a - 1) // 2) if m == mi else print(l.count(m) * l.count(mi))


t = int(input())
l = list(map(int, input().split()))
a = max(l)
b = min(l)
if b == a:
	n = l.count(a) - 1
	print(0, n * (n + 1) // 2)
else:
	c = a - b
	d = l.count(a)
	e = l.count(b)
	f = d * e
	print(c, f)


n = int(input())
a = list(map(int, input().split()))
p = max(a) - min(a)
if max(a) == min(a):
	w = a.count(max(a))
	w = w * (w - 1) // 2
else:
	w = a.count(max(a)) * a.count(min(a))
print(p, w)


n = int(input())
s = input().split()
li = []
mi = 1000000001
ma = 0
for i in range(n):
	k = int(s[i])
	li.append(k)
	if mi > k:
		mi = k
	if ma < k:
		ma = k
p = li.count(mi) * li.count(ma)
if mi == ma:
	p = int(li.count(mi) * (li.count(mi) - 1) / 2)
print(str(ma - mi) + ' ' + str(p))


import sys
from math import sqrt
mod = 1000000007
n = 1000000

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()

def print_array(a):
	print(' '.join(map(str, a)))

def main():
	n = int(input())
	a = get_array()
	(x, y) = (max(a), min(a))
	(cnt1, cnt2) = (0, 0)
	for e in a:
		if e == x:
			cnt1 += 1
		elif e == y:
			cnt2 += 1
	print(x - y, max(cnt1, cnt2) * (max(cnt1, cnt2) - 1) // 2 if cnt1 * cnt2 == 0 else cnt1 * cnt2)
main()


import math
a = int(input())
b = [int(x) for x in input().split()]
b.sort()
small = 0
big = 0
x = 0
length = len(b) - 1
if b[0] != b[length]:
	while b[x] == b[0]:
		small += 1
		x += 1
	x = length
	while b[x] == b[length]:
		big += 1
		x -= 1
	print(b[length] - b[0], small * big)
else:
	print(0, length * (length + 1) // 2)


n = int(input())
l = input().split()
for i in range(n):
	l[i] = int(l[i])
x = max(l)
y = min(l)
x1 = l.count(x)
y1 = l.count(y)
if x != y:
	print(x - y, x1 * y1)
else:
	print(0, x1 * (x1 - 1) // 2)


from collections import defaultdict, deque
from heapq import heappush, heappop
from math import inf
ri = lambda : map(int, input().split())

def solve():
	n = int(input())
	cnt = defaultdict(int)
	A = list(ri())
	for x in A:
		cnt[x] += 1
	A.sort()
	if A[-1] == A[0]:
		print(0, max(1, cnt[A[0]] * (cnt[A[0]] - 1) // 2))
		return
	print(A[-1] - A[0], cnt[A[0]] * cnt[A[-1]])
t = 1
while t:
	t -= 1
	solve()


n = int(input())
l = list(map(int, input().split()))
max = l[0]
min = l[0]
for i in range(n):
	if l[i] > max:
		max = l[i]
	if l[i] < min:
		min = l[i]
countermin = 0
countermax = 0
for i in range(n):
	if l[i] == max:
		countermax += 1
	if l[i] == min:
		countermin += 1
if min != max:
	print(max - min, countermax * countermin)
else:
	print(max - min, countermin * (countermin - 1) // 2)


try:
	t = int(input())
	l = list(map(int, input().split()))
	c = 0
	for i in range(t):
		if l[0] == l[i]:
			c = c + 1
	if c == t:
		k = 0
		for i in range(1, t):
			k = k + i
		print(0, end=' ')
		print(k)
	else:
		c1 = 0
		c2 = 0
		g1 = l[0]
		g = 0
		for i in range(t):
			if g < l[i]:
				g = l[i]
			elif g1 > l[i]:
				g1 = l[i]
		for i in range(t):
			if g == l[i]:
				c1 = c1 + 1
			elif g1 == l[i]:
				c2 = c2 + 1
		print(g - g1, end=' ')
		print(c1 * c2)
except Exception:
	pass


n = int(input())
li = list(map(int, input().split()))
mn = min(li)
mx = max(li)
diff = mx - mn
ways = 0
if diff == 0:
	for i in range(n):
		ways += i
else:
	ways = li.count(mx) * li.count(mn)
print(diff, ways)


def arin():
	arr = list(map(int, input().strip().split(' ')))
	return arr
n = int(input())
arr = arin()
if max(arr) != min(arr):
	print(max(arr) - min(arr), arr.count(max(arr)) * arr.count(min(arr)))
else:
	print(0, n * (n - 1) // 2)


n = int(input())
a = [int(i) for i in input().split()]
a = sorted(a)
if a[0] == a[n - 1]:
	if n == 2:
		print(0, 1)
	else:
		print(0, round(n * (n - 1) / 2))
else:
	k = 0
	for i in range(n):
		if a[i] == a[0]:
			k += 1
		else:
			break
	h = 0
	for i in range(n - 1, -1, -1):
		if a[i] == a[n - 1]:
			h += 1
		else:
			break
	print(a[n - 1] - a[0], end=' ')
	print(h * k)


from sys import stdin
n = int(input())
l = list(map(int, stdin.readline().rstrip().split(' ')))
l.sort()
c = 0
a = l[0]
b = l[-1]
d = 0
for i in l:
	if a == i:
		c += 1
	else:
		break
for i in range(n - 1, -1, -1):
	if l[i] == b:
		d += 1
	else:
		break
if c == d and c == n:
	print(0, n * (n - 1) // 2)
else:
	print(b - a, c * d)


n = int(input().strip())
ll = list(map(int, input().split()))
minll = min(ll)
maxll = max(ll)
if minll != maxll:
	kminll = 0
	kmaxll = 0
	for i in ll:
		if i == minll:
			kminll += 1
		elif i == maxll:
			kmaxll += 1
	print(maxll - minll, kmaxll * kminll)
else:
	print(0, n * (n - 1) // 2)


N = int(input())
B = list(map(int, input().split()))
maxv = max(B)
minv = min(B)
max_diff = maxv - minv
min_count = B.count(minv)
max_count = B.count(maxv)
if max_diff == 0:
	ans2 = min_count * (min_count - 1) // 2
else:
	ans2 = max_count * min_count
print('{} {}'.format(max_diff, ans2))


n = int(input())
b = [int(i) for i in input().split()]
mi = min(b)
ma = max(b)
a1 = ma - mi
if a1 == 0:
	a2 = len(b) * (len(b) - 1) // 2
else:
	a2 = b.count(mi) * b.count(ma)
print(a1, a2)


import math
n = int(input())
f = list(map(int, input().split()))
f.sort()
diff = f[-1] - f[0]
a = f[0]
b = f[-1]
c1 = 1
c2 = 1
for i in range(1, n - 1):
	if f[i] == a:
		c1 += 1
	elif f[i] == b:
		c2 += 1
if a == b:
	summ = 0
	for i in range(n - 1, 0, -1):
		summ += i
	print(diff, summ)
else:
	print(diff, c1 * c2)


import math
n = int(input())
l = list(map(int, input().split()))
mx = max(l)
mi = min(l)
if mx == mi:
	z = l.count(mx)
	print(0, z * (z - 1) // 2)
else:
	print(mx - mi, l.count(mx) * l.count(mi))


n = int(input())
line = list(map(int, input().split(' ')))
line.sort()
res = line[-1] - line[0]
a = line.count(line[-1])
b = line.count(line[0])
count = 0
if a == n or b == n:
	count = n * (n - 1) / 2
else:
	count = a * b
print(res, int(count))


from math import factorial
i = int(0)
x = int(0)
n = int(input())
a = [int(x) for x in input().split()]
mc = a.count(max(a))
minc = a.count(min(a))
if max(a) - min(a) != 0:
	print(max(a) - min(a), mc * minc)
else:
	print(max(a) - min(a), int((n - 1) * n / 2))


n = int(input())
b = sorted(map(int, input().split()))
x = min(b)
y = max(b)
cx = b.count(x)
cy = b.count(y)
print(y - x)
if x == y:
	print(cx * (cx - 1) // 2)
else:
	print(cx * cy)


n = int(input())
the_list = list(map(int, input().split()))
(a, b) = (max(the_list), min(the_list))
if b != a:
	ans = the_list.count(a) * the_list.count(b)
else:
	ans = n * (n - 1) // 2
print(a - b, ans)


from sys import stdin

def main():
	stdin.readline()
	l = list(map(int, stdin.readline().strip().split()))
	(mi, ma) = (min(l), max(l))
	(cmi, cma) = (l.count(mi), l.count(ma))
	print(ma - mi, cmi * cma if mi < ma else cmi * (cmi - 1) // 2)
main()


import sys
n = int(input())
inp = list(map(int, input().split()))
mxcount = inp.count(max(inp))
mncount = inp.count(min(inp))
if max(inp) == min(inp):
	print(max(inp) - min(inp), int(mxcount * (mxcount - 1) / 2))
	exit()
print(max(inp) - min(inp), mxcount * mncount)


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
n = iinput()
a = list(map(int, input().split()))
sum = 0
s = max(a) - min(a)
a1 = sorted(a)
if max(a) == min(a):
	for i in range(n):
		sum += i
	print(s, sum)
else:
	m1 = a.count(max(a))
	m2 = a.count(min(a))
	print(s, m1 * m2)


n = int(input())
s = list(map(int, input().split()))
x = max(s)
y = min(s)
if x == y:
	k = n * (n - 1) / 2
else:
	s1 = s.count(x)
	s2 = s.count(y)
	k = s1 * s2
print(x - y, int(k))


n = int(input())
lis = list(map(int, input().split()))
lis.sort()
mini = lis[0]
maxi = lis[len(lis) - 1]
diff = maxi - mini
(countmax, countmin) = (0, 0)
(start, end) = (0, len(lis) - 1)
for i in range(len(lis)):
	if maxi == mini:
		countmax = n
		countmin = (n - 1) / 2
		break
	if lis[start] == mini:
		countmin += 1
		start += 1
	elif lis[end] == maxi:
		countmax += 1
		end -= 1
	else:
		break
print(diff, int(countmax * countmin))


n = int(input())
b = [int(i) for i in input().split()]
bmax = max(b)
bmin = min(b)
maxocc = b.count(bmax)
minocc = b.count(bmin)
maxbeau = bmax - bmin
if bmax != bmin:
	beauocc = maxocc * minocc
else:
	beauocc = (maxocc ** 2 - maxocc) // 2
print(maxbeau, beauocc)


n = int(input())
a = list(map(int, input().split(' ')))
a = sorted(a)
max = a[-1] - a[0]
p = a[0]
q = a[-1]
x = a.count(p)
y = a.count(q)
ans = x * y
if p == q:
	print('%d %d' % (max, n * (n - 1) / 2))
else:
	print('%d %d' % (max, ans))


n = int(input())
l = list(map(int, input().split()))
x = max(l)
y = min(l)
if x == y:
	print('0', n * (n - 1) // 2)
else:
	z = x - y
	p = l.count(x)
	q = l.count(y)
	print(z, p * q)


n = int(input())
l = [int(j) for j in input().split()]
mn = min(l)
mx = max(l)
kmx = 0
kmn = 0
for i in range(n):
	if l[i] == mx:
		kmx += 1
	if l[i] == mn:
		kmn += 1
if mn == mx:
	print(mx - mn, n * (n - 1) // 2)
else:
	print(mx - mn, kmx * kmn)


n = int(input())
a = [int(x) for x in input().split()]
imin = a[0]
imax = a[0]
kol_imin = 1
kol_imax = 1
for i in range(1, n):
	if a[i] > imax:
		imax = a[i]
		kol_imax = 1
	elif a[i] == imax:
		kol_imax += 1
	if a[i] < imin:
		imin = a[i]
		kol_imin = 1
	elif a[i] == imin:
		kol_imin += 1
if imax == imin:
	print(0, kol_imax * (kol_imax - 1) // 2)
else:
	print(imax - imin, kol_imin * kol_imax)


n = int(input())
a = [int(x) for x in input().split()]
ma = max(a)
mi = min(a)
k_ma = 0
k_mi = 0
for i in a:
	if i == ma:
		k_ma += 1
	if i == mi:
		k_mi += 1
print(str(ma - mi) + ' ' + str(int(n * (n - 1) / 2) if ma == mi else k_ma * k_mi))


import sys
sys.setrecursionlimit(10 ** 5)
readline = sys.stdin.readline

def process():
	n = int(readline())
	a = list(map(int, readline().strip().split()))
	a.sort()
	max_diff = a[-1] - a[0]
	if max_diff == 0:
		print('{} {}'.format(max_diff, n * (n - 1) // 2))
		return
	x = a.count(a[-1]) * a.count(a[0])
	print('{} {}'.format(max_diff, x))
process()


n = int(input())
a = list(map(int, input().split()))
a.sort()
l = a[0]
h = a[-1]
diff = h - l
lows = 0
highs = 0
i = 0
while i < n and a[i] == l:
	lows += 1
	i += 1
if l != h:
	j = 0
	j = n - 1
	while j > 0 and a[j] == h:
		highs += 1
		j -= 1
	print(diff, highs * lows)
else:
	ans = (lows - 1) / 2 * lows
	print(diff, int(ans))


def fac(n):
	return n * (n - 1) // 2
n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[0] != a[-1]:
	print(a[-1] - a[0], a.count(a[0]) * a.count(a[-1]), end=' ')
else:
	print(a[-1] - a[0], fac(a.count(a[0])), end=' ')


a = int(input())
b = input()
k = 1
p = 1
cvetok = b.split()
for t in range(0, a):
	cvetok[t] = int(cvetok[t])
cvetok.sort()
max = abs(cvetok[0] - cvetok[a - 1])
for i in range(1, a):
	if cvetok[0] == cvetok[i]:
		k = k + 1
for j in range(a - 2, -1, -1):
	if cvetok[a - 1] == cvetok[j]:
		p = p + 1
chislo = p * k
if cvetok[0] == cvetok[a - 1]:
	chislo = a * (a - 1) // 2
print(max, chislo)


import sys
n = int(sys.stdin.readline())
(m1, cnt1) = (10 ** 9 + 1, 0)
(m2, cnt2) = (0, 0)
for x in map(int, sys.stdin.readline().split()):
	if x < m1:
		m1 = x
		cnt1 = 1
	elif x == m1:
		cnt1 += 1
	if x > m2:
		m2 = x
		cnt2 = 1
	elif x == m2:
		cnt2 += 1
cnt = 0
if m1 == m2:
	cnt = cnt1 * (cnt1 - 1) // 2
else:
	cnt = cnt1 * cnt2
sys.stdout.write('%d %d\n' % (m2 - m1, cnt))


from collections import defaultdict
import sys
n = int(input())
arr = list(map(int, input().split()))
d = defaultdict(int)
mi = int(sys.maxsize)
ma = 0
for i in arr:
	d[i] += 1
	if i > ma:
		ma = i
	if i < mi:
		mi = i
diff = ma - mi
if diff != 0:
	cnt = d[ma] * d[mi]
	print(diff, cnt)
else:
	cnt = n * (n - 1) // 2
	print(diff, cnt)


import operator as op
from functools import reduce

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom
inp = lambda : map(int, input().split())
n = int(input())
l = list(inp())
if max(l) != min(l):
	print(max(l) - min(l), l.count(max(l)) * l.count(min(l)))
else:
	print(max(l) - min(l), int(ncr(l.count(max(l)), 2)))


n = int(input())
c = list(map(int, input().split()))
l1 = max(c) - min(c)
if max(c) == min(c):
	print(l1, n * (n - 1) // 2)
else:
	l2 = c.count(max(c)) * c.count(min(c))
	print(l1, l2)


n = int(input())
l = list(map(int, input().split()))
l.sort()
print(l[n - 1] - l[0], end=' ')
x = 1
y = 1
if l[n - 1] - l[0] != 0:
	for i in range(1, n):
		if l[i] == l[0]:
			x += 1
		else:
			break
	for i in range(n - 2, -1, -1):
		if l[n - 1] == l[i]:
			y += 1
		else:
			break
	print(x * y)
else:
	print(n * (n - 1) // 2)


n = int(input())
beauty = [int(x) for x in input().split()]
beauty.sort()
difference = beauty[-1] - beauty[0]
if n == 2:
	way = 1
else:
	max_num = beauty.count(beauty[-1])
	min_num = beauty.count(beauty[0])
	if beauty[-1] == beauty[0]:
		way = n * (n - 1) // 2
	else:
		way = max_num * min_num
print(difference, way)


x = input()
y = sorted(list(map(int, input().split())))
maxdiff = y[-1] - y[0]
if maxdiff == 0:
	print(f'0 {int(len(y) * (len(y) - 1) / 2)}')
else:
	lowMult = 1
	for i in range(1, len(y)):
		if y[i] == y[0]:
			lowMult += 1
		else:
			break
	highMult = 1
	for i in range(len(y) - 2, 0, -1):
		if y[i] == y[-1]:
			highMult += 1
		else:
			break
	maxcount = lowMult * highMult
	print(f'{maxdiff} {maxcount}')


n = int(input())
a = list(map(int, input().split()))
mx = max(a)
mi = min(a)
print(mx - mi, end=' ')
print(n * (n - 1) // 2 if mx == mi else a.count(mx) * a.count(mi))


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
diff = arr[n - 1] - arr[0]
if diff == 0:
	print('%d %d' % (diff, int(n * (n - 1) / 2)))
else:
	i = 0
	j = n - 1
	counta = 0
	countb = 0
	while diff == arr[j] - arr[i] and j > i:
		counta += 1
		j -= 1
	j += 1
	while diff == arr[j] - arr[i] and j > i:
		countb += 1
		i += 1
	print('%d %d' % (diff, countb * counta))


n = int(input())
m = list(map(int, input().split()))
ma = max(m)
mi = min(m)
mac = m.count(ma)
mic = m.count(mi)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res
if mi != ma:
	print(ma - mi, mac * mic)
else:
	print(0, int(nCr(mac, 2)))


n = int(input())
nums = list(map(int, input().split()))
nums.sort()
dif = nums[-1] - nums[0]
cnt = 0
if dif == 0:
	cnt = len(nums) * (len(nums) - 1) // 2
else:
	cmin = 0
	for i in range(len(nums)):
		if nums[i] == nums[0]:
			cmin += 1
		else:
			break
	cmax = 0
	for i in range(len(nums)):
		if nums[-i - 1] == nums[-1]:
			cmax += 1
		else:
			break
	cnt = cmin * cmax
print(str(dif) + ' ' + str(cnt))


from sys import exit
n = int(input())
v = [int(x) for x in input().split()]
l = max(v)
s = min(v)
if l == s:
	print('%d %d' % (l - s, n * (n - 1) // 2))
	exit(0)
p = v.count(l)
q = v.count(s)
print('%d %d' % (l - s, p * q))


N = int(input())
b = list(map(int, input().strip().split()))
b = sorted(b)
(min, max) = (b[0], b[-1])
(i, j) = (1, len(b) - 1)
while i < len(b) and b[i] == b[i - 1]:
	i += 1
while j > 0 and b[j] == b[j - 1]:
	j -= 1
print(max - min, i * (len(b) - j) if max != min else N * (N - 1) // 2)


n = int(input())
a = list(map(int, input().split()))
x = min(a)
y = max(a)
ans = a.count(x) * a.count(y)
if x == y:
	k = a.count(x)
	ans = n * (n - 1) // 2
	print(*(0, ans))
else:
	print(*(y - x, ans))


f = int(input())
lst = list(map(int, input().split()))
mb = max(lst) - min(lst)
if mb:
	print(mb, lst.count(max(lst)) * lst.count(min(lst)))
else:
	print(0, f * (f - 1) // 2)


n = int(input())
b = list(map(int, input().split()))
b.sort()
x = b[0]
X = 0
for i in b:
	if i == x:
		X += 1
	else:
		break
y = b[-1]
Y = 0
for i in b[::-1]:
	if i == y:
		Y += 1
	else:
		break
if x == y:
	print(0, n * (n - 1) // 2)
else:
	print(y - x, X * Y)


n = int(input())
f = input().split()
for i in range(n):
	f[i] = int(f[i])
maxf = 0
minf = 10 ** 9
for i in f:
	maxf = max(maxf, i)
	minf = min(minf, i)
cmax = 0
cmin = 0
if maxf == minf:
	if n == 2:
		print(0, 1)
	else:
		print(0, n * (n - 1) // 2)
else:
	for i in f:
		if i == maxf:
			cmax += 1
		if i == minf:
			cmin += 1
	print(maxf - minf, cmax * cmin)


f = input()
t = input()
li = t.split(' ')
ma = 0
mi = 1000000010
coma = 0
comi = 0
for i in li:
	if int(i) > ma:
		ma = int(i)
		coma = 0
	if int(i) < mi:
		mi = int(i)
		comi = 0
	if int(i) == ma:
		coma += 1
	if int(i) == mi:
		comi += 1
if mi == ma:
	a = len(li) * (len(li) - 1) // 2
	print('0', a)
else:
	print(ma - mi, coma * comi)


import math
from collections import Counter
n = int(input())
b = [int(i) for i in input().split()]
b.sort()
maxd = b[n - 1] - b[0]
ans = 0
d = Counter(b)
for i in range(0, n):
	if maxd != 0:
		ans += d[b[i]] * d[b[i] + maxd]
		d[b[i]] = 0
	elif d[b[i]] > 1:
		ans += n * (n - 1) // 2
		d[b[i]] = 0
print(maxd, ans)


import math
n = int(input())
bis = list(map(int, input().split()))
(i, j) = (max(bis), min(bis))
print(i - j, n * (n - 1) // 2 if i == j else bis.count(i) * bis.count(j))


number = int(input())
flowers = list(map(int, input().split(' ')))
setflowers = set(flowers)
listflowers = list(setflowers)
listflowers.sort()
max = int(listflowers[len(listflowers) - 1]) - int(listflowers[0])
if max == 0:
	count1 = flowers.count(int(listflowers[0]))
	count2 = count1 - 1
	possibilities = count1 * count2 // 2
else:
	count1 = flowers.count(int(listflowers[0]))
	count2 = flowers.count(int(listflowers[len(listflowers) - 1]))
	possibilities = count1 * count2
print(max, possibilities)


n = int(input())
beauty_flower = [int(x) for x in input().split(' ')]
beauty_flower = sorted(beauty_flower)
max_difference = beauty_flower[len(beauty_flower) - 1] - beauty_flower[0]
a = beauty_flower.count(beauty_flower[0])
b = beauty_flower.count(beauty_flower[len(beauty_flower) - 1])
if beauty_flower[0] == beauty_flower[len(beauty_flower) - 1]:
	max_ways = n * (n - 1) / 2
else:
	max_ways = a * b
print(max_difference, int(max_ways))


n = int(input())
b = input().split(' ')
for i in range(n):
	b[i] = int(b[i])
cnt_min = b.count(min(b))
cnt_max = b.count(max(b))
if min(b) == max(b):
	print(max(b) - min(b), cnt_min * (cnt_min - 1) // 2)
else:
	print(max(b) - min(b), cnt_min * cnt_max)


n = int(input())
list1 = sorted(list(map(int, input().split(' '))))
(mini, maxi) = (min(list1), max(list1))
mic = list1.count(mini)
mac = list1.count(maxi)
if 2 * n == mac + mic:
	print(maxi - mini, mic * (mic - 1) // 2)
else:
	print(maxi - mini, mic * mac)


n = int(input())
a = list(map(int, input().split()))
a.sort()
b = a.count(a[0])
c = a.count(a[n - 1])
s = 0
if a[0] == a[n - 1]:
	for i in range(b - 1, 0, -1):
		s = s + i
else:
	for i in range(b):
		s = s + c
print(a[n - 1] - a[0], s)


input()
a = sorted(list(map(int, input().split())))
if len(set(a)) == 1:
	print(0, len(a) * (len(a) - 1) // 2)
else:
	print(a[-1] - a[0], a.count(a[-1]) * a.count(a[0]))


n = int(input())
flow = list(map(int, input().split()))
flow.sort()
diff = flow[-1] - flow[0]
x = flow.count(flow[0])
y = flow.count(flow[-1])
if flow[0] == flow[-1]:
	print(diff, x * (x - 1) // 2)
else:
	print(diff, int(x * y))


flowers = int(input())
beauty = []
for i in input().split():
	beauty.append(int(i))
maxB = max(beauty)
minB = min(beauty)
diff = abs(maxB - minB)
total = 0
if maxB != minB:
	countMax = beauty.count(maxB)
	countMin = beauty.count(minB)
	print('{} {}'.format(diff, countMax * countMin))
else:
	print('{} {}'.format(diff, flowers * (flowers - 1) // 2))


n = int(input())
l = [int(k) for k in input().split(' ')]
if max(l) == min(l):
	print(0, n * (n - 1) // 2)
else:
	print(max(l) - min(l), l.count(max(l)) * l.count(min(l)))


n = int(input())
cx = cm = 0
small = 10 ** 9
m = 1
for i in input().split():
	i = int(i)
	if i > m:
		m = i
		cx = 0
	if i == m:
		cx += 1
	if i < small:
		small = i
		cm = 0
	if i == small:
		cm += 1
if m != small:
	print(m - small, cx * cm)
else:
	print(m - small, (n - 1) * n // 2)


n = int(input())
B = list(map(int, input().split()))
no_of_min = 1
no_of_max = 1
B.sort()
mi = B[0]
ma = B[-1]
if mi == ma:
	ans = int(n * (n - 1) / 2)
else:
	for i in range(1, n - 1):
		if B[i] == mi:
			no_of_min += 1
		else:
			break
	for i in range(n - 2, 0, -1):
		if B[i] == ma:
			no_of_max += 1
		else:
			break
	ans = no_of_min * no_of_max
print(B[-1] - B[0], ans)


def function1(n, a):
	amax = max(a)
	amin = min(a)
	buity = amax - amin
	if buity == 0:
		return str(buity) + ' ' + str(n * (n - 1) // 2)
	k = a.count(amax) * a.count(amin)
	return str(buity) + ' ' + str(k)

def main():
	n = int(input())
	a = list(map(int, input().split()))
	print(function1(n, a))
main()


from math import factorial
import re
n = int(input())
flowers = list(map(int, input().split()))
(first, last) = (max(flowers), min(flowers))
if first != last:
	total = flowers.count(first) * flowers.count(last)
else:
	total = n * (n - 1) // 2
print(f'{first - last} {total}')


import sys
import heapq
from collections import deque
from collections import defaultdict
I = lambda : list(map(int, input().split(' ')))
n = int(input())
lst = I()
m1 = max(lst)
m2 = min(lst)
if m1 != m2:
	(cnt_min, cnt_max) = (0, 0)
	for ele in lst:
		if m1 == ele:
			cnt_min += 1
		if m2 == ele:
			cnt_max += 1
	print(m1 - m2, end=' ')
	print(cnt_min * cnt_max)
else:
	print(0, end=' ')
	print(n * (n - 1) // 2)


n = int(input())
array = input().split()
for i in range(n):
	array[i] = int(array[i])
maxElement = 0
minElement = 1000000001
maxCount = 0
minCount = 0
for number in array:
	if number > maxElement:
		maxElement = number
		maxCount = 1
	elif number == maxElement:
		maxCount += 1
	if number < minElement:
		minElement = number
		minCount = 1
	elif number == minElement:
		minCount += 1
print(maxElement - minElement, end=' ')
if maxElement != minElement:
	print(maxCount * minCount)
else:
	print(int(maxCount * (maxCount - 1) / 2))


import math
n = input()
a = list(map(int, input().split()))
m1 = max(a)
m2 = min(a)
d = m1 - m2
if d == 0:
	c = a.count(m1)
	print(0, c * (c - 1) // 2)
else:
	print(d, a.count(m1) * a.count(m2))


import math

def Pashmak(inp):
	s = [int(x) for x in inp.split()]
	s.sort()
	i1 = int(s[0])
	i2 = int(s[-1])
	diff = i2 - i1
	a = s.count(i1)
	b = s.count(i2)
	if i1 == i2:
		return [diff, a * (a - 1) // 2]
	else:
		return [diff, a * b]

def main():
	inp2 = input()
	inp = input()
	res = Pashmak(inp)
	print(res[0], res[1])
main()


n = int(input())
lis = input().split()
for i in range(n):
	lis[i] = int(lis[i])
m = min(lis)
M = max(lis)
print(M - m, end=' ')
if M != m:
	c1 = 0
	c2 = 0
	for i in range(n):
		if lis[i] == m:
			c1 += 1
		if lis[i] == M:
			c2 += 1
	print(c1 * c2)
else:
	print(int(n * (n - 1) / 2))


import sys
n = int(input())
a = [int(i) for i in input().split(' ')]
mink = min(a)
maxk = max(a)
k1 = 0
k2 = 0
for i in a:
	if i == mink:
		k1 += 1
	elif i == maxk:
		k2 += 1
print(maxk - mink, k1 * k2 if maxk - mink != 0 else int((k1 - 1) * k1 / 2))


n = int(input())
data = [int(i) for i in input().split()]
diff = max(data) - min(data)
if max(data) == min(data):
	c = data.count(max(data)) * (data.count(max(data)) - 1) // 2
else:
	c = data.count(max(data)) * data.count(min(data))
print(diff, c)


n = int(input())
a = list(map(int, input().split()))
a.sort()
d = a[-1] - a[0]
count = 0
x = a.count(a[-1])
y = a.count(a[0])
if a[-1] == a[0]:
	count = n * (n - 1) // 2
else:
	count = x * y
print('{} {}'.format(d, count))


n = int(input())
b = [int(c) for c in input().split(' ')]
minimal = min(b)
maximal = max(b)
max_diff = maximal - minimal
if max_diff != 0:
	min_occ = b.count(minimal)
	max_occ = b.count(maximal)
	ways = max_occ * min_occ
else:
	ways = int(n * (n - 1) / 2)
print(max_diff, ways)


n = int(input())
x = input()
x = x.split()
for i in range(n):
	x[i] = int(x[i])
x = sorted(x)
ma = max(x)
mi = min(x)
res = ma - mi
c1 = x.count(ma)
c2 = x.count(mi)
res2 = c1 * c2
if ma == mi:
	res2 = 0
	for i in range(c1 - 1, 0, -1):
		res2 += i
print(res, res2)


n = int(input())
b = list(map(int, input().split()))
flowers = sorted(enumerate(b, 1), key=lambda x: x[1])
(min_b, max_b) = (flowers[0][1], flowers[-1][1])
ans = max_b - min_b
if ans == 0:
	print(ans, b.count(max_b) * (b.count(max_b) - 1) // 2)
else:
	print(max_b - min_b, b.count(min_b) * b.count(max_b))


def main():
	n = int(input())
	l = list(map(int, input().split(' ')))
	maximal = max(l)
	minimal = min(l)
	if maximal == minimal:
		print('0 %d' % (n * (n - 1) / 2))
		return
		pass
	nmin = 0
	nmax = 0
	nmin = l.count(minimal)
	nmax = l.count(maximal)
	print('%d %d' % (maximal - minimal, nmax * nmin))
main()


n = int(input())
b = list(map(int, input().split()))
b.sort()
if n == 1:
	print(0, 0)
else:
	maxi = b[-1] - b[0]
	ways1 = 1
	ways2 = 1
	i = 1
	while b[0] == b[i]:
		ways1 += 1
		i += 1
		if i == n:
			break
	if ways1 == n:
		print(0, n * (n - 1) // 2)
	else:
		i = -2
		while b[-1] == b[i] and i >= -n:
			ways2 += 1
			i -= 1
		ways = ways1 * ways2
		print(maxi, ways)


n = int(input())
b = [int(i) for i in input().split()]
c = b.count(max(b)) * b.count(min(b))
d = max(b) - min(b)
if d == 0:
	c = n * (n - 1) // 2
print(d, c)


n = int(input())
b = list(map(int, input().split()))
b.sort()
i = 0
j = len(b) - 1
sm = 0
bg = 0
while b[i] == b[0]:
	sm += 1
	i += 1
	if i == len(b):
		break
while b[j] == b[-1]:
	bg += 1
	j -= 1
	if j == -1:
		break
if b[0] == b[-1]:
	print(0, len(b) * (len(b) - 1) // 2)
else:
	print(b[-1] - b[0], bg * sm)


n = int(input())
b = list(map(int, input().strip().split(' ')))
b.sort()
dif = b[-1] - b[0]
cnt = 0
if b[0] != b[-1]:
	cnt = b.count(b[0]) * b.count(b[-1])
else:
	for i in range(1, n):
		cnt += i
print(dif, cnt)


n = int(input())
line = [int(i) for i in input().split()]
a = max(line)
b = min(line)
print(a - b, end=' ')
counta = 0
countb = 0
if not a == b:
	for i in line:
		if i == a:
			counta += 1
		if i == b:
			countb += 1
	print(counta * countb)
else:
	print(int(n * (n - 1) / 2))


n = int(input())
bs = [int(x) for x in input().split()]
(M, m) = (max(bs), min(bs))
(M_num, m_num) = (bs.count(M), bs.count(m))
if M == m:
	ways = int(M_num * (M_num - 1) / 2)
else:
	ways = M_num * m_num
print(M - m, ways)


def flowers(li):
	if max(li) == min(li):
		print(max(li) - min(li), len(li) * (len(li) - 1) // 2)
	else:
		max_ = li.count(max(li))
		min_ = li.count(min(li))
		print(max(li) - min(li), max_ * min_)
n = int(input())
li = [int(x) for x in input().split()]
flowers(li)


n = int(input())
li = [int(i) for i in input().split()]
max_num = max(li)
min_num = min(li)
if max_num != min_num:
	print(max_num - min_num, li.count(max_num) * li.count(min_num))
else:
	print(0, li.count(max_num) * (li.count(max_num) - 1) // 2)


n = int(input())
a = [int(x) for x in input().split()]
min = a[0]
minc = 1
max = a[0]
maxc = 1
for i in range(1, n):
	if a[i] < min:
		min = a[i]
		minc = 1
	elif a[i] == min:
		minc += 1
	if a[i] > max:
		max = a[i]
		maxc = 1
	elif a[i] == max:
		maxc += 1
if max != min:
	print(max - min, maxc * minc)
else:
	print(0, int(maxc * (maxc - 1) / 2))


q = int(input())
w = list(map(int, input().split()))
e = max(w)
r = min(w)
if e == r:
	print(str(e - r), str(w.count(e) * (w.count(e) - 1) // 2))
else:
	print(str(e - r), str(w.count(e) * w.count(r)))


x = int(input())
a = list(map(int, input().split()))
v = min(a)
minimum = a.count(v)
x = max(a)
maximum = a.count(x)
if v == x:
	x = 0
	for i in range(minimum):
		x += i
	print(0, x)
else:
	print(x - v, minimum * maximum)


from itertools import combinations
from collections import Counter
num_flowers = int(input())
beauty = Counter((int(i) for i in input().split()))
max_ = max(beauty.keys())
min_ = min(beauty.keys())
max_beauty = max_ - min_
if max_ != min_:
	num_ways = beauty[max_] * beauty[min_]
else:
	num_ways = beauty[max_] * (beauty[max_] - 1) // 2
print(max_beauty, num_ways)


n = int(input())
l = list(map(int, input().split()))
mini = min(l)
maxi = max(l)
count = l.count(mini)
print(maxi - mini, l.count(mini) * l.count(maxi) if mini != maxi else count * (count - 1) // 2, sep=' ')


n = int(input())
li = list(map(int, input().split()))
flag = True
for i in range(n - 1):
	flag &= li[i] == li[i + 1]
if flag:
	print('0 ' + str(n * (n - 1) // 2))
	quit()
li.sort()
i = 1
j = n - 2
while li[i - 1] == li[i]:
	i += 1
while li[j + 1] == li[j]:
	j -= 1
print(str(li[-1] - li[0]) + ' ' + str(i * (n - 1 - j)))


from collections import Counter
import string
import math
import sys
sys.setrecursionlimit(10 ** 6)

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(number_of_variables):
	if number_of_variables == 1:
		return int(sys.stdin.readline())
	if number_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
n = vary(1)
num = array_int()
num.sort()
if num[-1] == num[0]:
	print(0, (n - 1) * n // 2)
	exit()
min_count = max_count = 0
mini = num[0]
for i in num:
	if i == mini:
		min_count += 1
	else:
		break
maxi = num[-1]
for i in range(n - 1, -1, -1):
	if num[i] == maxi:
		max_count += 1
print(maxi - mini, max_count * min_count)


h = int(input())
a = list(map(int, input().split()))
a.sort()
x = 0
y = 0
m = a[h - 1] - a[0]
for t in a:
	if t == a[0]:
		x += 1
	elif t == a[h - 1]:
		y += 1
u = x * y
g = int(h * (h - 1) / 2)
if u == 0:
	print(f'{m} {g}')
else:
	print(f'{m} {u}')


n = int(input(''))
num = [int(x) for x in input('').split()]
num.sort()
first = num[0]
last = num[-1]
dif = last - first
s = [x for x in range(1, len(num))]
res = sum(s)
if dif != 0:
	(p1, p2) = (1, 1)
	index = 1
	while num[index] == first:
		p1 += 1
		index += 1
	index = len(num) - 2
	while num[index] == last:
		p2 += 1
		index -= 1
	res = p1 * p2
print(dif, res)


import os
import sys
from io import BytesIO, IOBase
from bisect import bisect_left, bisect_right

def main():
	n = int(input())
	b = list(map(int, input().split()))
	b.sort()
	x = bisect_right(b, b[0])
	y = n - bisect_left(b, b[-1])
	if b[-1] == b[0]:
		print(0, n * (n - 1) // 2)
		return
	print(b[-1] - b[0], x * y)

def nouse0():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse1():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse2():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def nouse3():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse4():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse5():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
main()


n = int(input())
a = list(map(int, input().split()))
mx = max(a)
mi = min(a)
c1 = a.count(mx)
c2 = a.count(mi)
if mx == mi:
	print(0, n * (n - 1) // 2)
else:
	print(mx - mi, c1 * c2)


n = int(input())
b = list(map(int, input().split()))
a = max(b)
c = min(b)
d = b.count(a)
e = b.count(c)
de = d * e
if a == c:
	de = n * (n - 1) / 2
print(a - c, int(de))


def answer(n, b):
	mn = min(b)
	mx = max(b)
	cmn = b.count(mn)
	cmx = b.count(mx)
	d = mx - mn
	if d == 0:
		if n % 2 == 0:
			numcombo = n * (n // 2 - 1) + n // 2
		else:
			numcombo = n * (n // 2)
		print(d, numcombo)
		return
	print(d, cmx * cmn)
	return

def main():
	n = int(input())
	b = [int(i) for i in input().split()]
	answer(n, b)
main()


n = input()
a = list(map(int, input().split()))
(mi, ma) = (10 ** 9 + 1, 0)
for el in a:
	if el < mi:
		mi = el
	if el > ma:
		ma = el
(cmi, cma) = (0, 0)
for el in a:
	if el == mi:
		cmi += 1
	if el == ma:
		cma += 1
if mi == ma:
	print(0, cmi * (cmi - 1) // 2)
else:
	print(ma - mi, cmi * cma)


n = int(input())
a = [int(i) for i in input().split()]
(maxim, minim) = (a[0], a[0])
(maxctr, minctr) = (1, 1)
for elem in a[1:]:
	if elem == maxim:
		maxctr += 1
	if elem == minim:
		minctr += 1
	if elem > maxim:
		maxim = elem
		maxctr = 1
	elif elem < minim:
		minim = elem
		minctr = 1
if maxim != minim:
	print(maxim - minim, maxctr * minctr)
else:
	print(maxim - minim, maxctr * (maxctr - 1) // 2)


import sys
import math
n = int(sys.stdin.readline())
rc = [int(x) for x in sys.stdin.readline().split()]
rc.sort()
vmin = rc[0]
lrc = len(rc)
vmax = rc[lrc - 1]
if vmax == vmin:
	cnt = 0
	if lrc % 2 == 0:
		cnt = int(lrc / 2) * (lrc - 1)
	else:
		cnt = int(lrc / 2) * lrc
	print(str(vmax - vmin) + ' ' + str(int(cnt)))
	exit()
cmin = 0
cmax = 0
for i in rc:
	if i == vmin:
		cmin += 1
	else:
		break
for i in range(lrc - 1, -1, -1):
	if vmax == rc[i]:
		cmax += 1
	else:
		break
print(str(vmax - vmin) + ' ' + str(cmax * cmin))


import os, sys
from io import BytesIO, IOBase
import math

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def Diff(li1, li2):
	return list(set(li1) - set(li2))
n = ii()
a = li()
b = max(a)
c = min(a)
ans = b - c
b = a.count(b)
c = a.count(c)
if ans == 0:
	print(ans, c * (c - 1) // 2)
else:
	print(ans, b * c)


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)
n = int(input())
l = list(map(int, input().split(' ')))
v1 = max(l)
v2 = min(l)
c1 = 0
c2 = 0
for i in l:
	if i == v1:
		c1 = c1 + 1
	elif i == v2:
		c2 = c2 + 1
if v1 != v2:
	print(v1 - v2, c1 * c2)
else:
	print(v1 - v2, n * (n - 1) // 2)


class CodeforcesTask459BSolution:

	def __init__(self):
		self.result = ''
		self.n = []
		self.array = []

	def read_input(self):
		self.n = int(input())
		self.array = [int(x) for x in input().split(' ')]

	def process_task(self):
		mx = max(self.array)
		mn = min(self.array)
		diff = mx - mn
		mxc = self.array.count(mx)
		mnc = self.array.count(mn)
		if diff:
			self.result = '{0} {1}'.format(diff, mxc * mnc)
		else:
			self.result = '0 {0}'.format(mxc * (mxc - 1) // 2)

	def get_result(self):
		return self.result
Solution = CodeforcesTask459BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
a = list(map(int, input().strip().split(' ')))
a.sort()
if max(a) == min(a):
	print(0, n * (n - 1) // 2)
else:
	print(max(a) - min(a), a.count(max(a)) * a.count(min(a)))


input()
b = sorted(map(int, input().split()))
(d, c1, c2) = (b[-1] - b[0], b.count(b[-1]), b.count(b[0]))
if d == 0:
	c1 = 0
	while c2:
		c2 -= 1
		c1 += c2
print(d, c1 * c2 if d else c1)


from sys import stdin

def solve():
	n = int(input())
	f = [int(i) for i in stdin.readline().split()]
	if len(set(f)) == 1:
		return (0, int((n - 1) * n / 2))
	f.sort()
	if n == 2:
		return (f[-1] - f[0], 1)
	(lc, rc) = (0, 0)
	(l, r) = (f[0], f[-1])
	mx = r - l
	for i in range(len(f)):
		if f[i] == l:
			lc += 1
		else:
			break
	for j in range(len(f) - 1, -1, -1):
		if f[j] == r:
			rc += 1
		else:
			break
	return (mx, lc * rc)
ans = solve()
print(ans[0], ans[1])


fl = int(input())
bs = sorted([int(b) for b in input().split()])
diff = bs[fl - 1] - bs[0]
x = 0
y = 0
ans = 0
start = bs[0]
end = bs[fl - 1]
if start != end:
	for i in range(0, fl):
		if bs[i] == start:
			x = x + 1
		if bs[fl - 1 - i] == end:
			y = y + 1
	ans = x * y
else:
	tmp = fl * (fl - 1) / 2
	ans = int(tmp)
print(diff, ans)


N = int(input())
arr = list(map(int, input().split()))
arr.sort()
_min_ = arr[-1] - arr[0]
if len(set(arr)) == 1:
	print(_min_, N * (N - 1) // 2)
else:
	print(_min_, arr.count(arr[-1]) * arr.count(arr[0]))


n = int(input())
L = list(map(int, input().split(' ')))
L.sort()
mini = L[0]
maxi = L[n - 1]
r = maxi - mini
i = 0
count_mini = 0
count_maxi = 0

def C(n, k):
	if 0 <= k <= n:
		nn = 1
		kk = 1
		for t in range(1, min(k, n - k) + 1):
			nn *= n
			kk *= t
			n -= 1
		return nn // kk
	else:
		return 0
if r == 0:
	print(0, int(n * (n - 1) / 2))
else:
	while i < n and L[i] == mini:
		count_mini += 1
		i += 1
	i = n - 1
	while i >= 0 and L[i] == maxi:
		count_maxi += 1
		i -= 1
	print(r, count_maxi * count_mini)


n = int(input())
a = list(map(int, input().split()))
a.sort()
m = a[n - 1] - a[0]
if n == 2 and a[0] == a[1]:
	print(0, 1)
elif a.count(a[0]) == n:
	z = n * (n - 1) // 2
	print(m, z)
else:
	z = a.count(a[n - 1]) - a.count(a[0])
	p = [a[0]] * a.count(a[0])
	q = [a[n - 1]] * a.count(a[n - 1])
	s = 0
	print(m, len(p) * len(q))


n = int(input())
l = list(map(int, input().split()))
z = max(l) - min(l)
x = l.count(max(l))
x1 = l.count(min(l))
if z == 0:
	print(z, n * (n - 1) // 2)
else:
	print(z, x * x1)


n = int(input())
l = [int(i) for i in input().split()]
l = sorted(l)
max = l[n - 1] - l[0]
t = l.count(l[n - 1]) * l.count(l[0])
if max == 0:
	t = (n - 1) * n // 2
print(max, t)


def solve():
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	s1 = lst[-1] - lst[0]
	j = len(lst) - 1
	s2 = 0
	c = 0
	for i in range(len(lst)):
		if lst[i] != lst[0]:
			break
		else:
			s2 += 1
	if s2 == n:
		print(0, int(s2 * (s2 - 1) / 2))
		return
	for i in range(len(lst) - 1, -1, -1):
		if lst[i] != lst[-1]:
			break
		else:
			c += 1
	print(lst[-1] - lst[0], int(s2 * c))
solve()


n = int(input())
l = list(map(int, input().split()))
l.sort()
if len(set(l)) == 1:
	print(l[-1] - l[0], int(n * ((n - 1) / 2)))
else:
	k = l.count(max(l))
	m = l.count(min(l))
	print(l[-1] - l[0], k * m)


n = int(input())
x = list(map(int, input().split()))
a = min(x)
b = max(x)
d = x.count(a)
e = x.count(b)
if a != b:
	print(b - a, d * e)
else:
	print(0, int(n * (n - 1) / 2))


def arr_inp():
	return [int(x) for x in stdin.readline().split()]

def nCr(n, r):
	(f, m) = (factorial, 1)
	for i in range(n, n - r, -1):
		m *= i
	return int(m // f(r))
from math import *
from sys import *
(n, a) = (int(input()), sorted(arr_inp()))
(ma, way1, way2) = (a[-1] - a[0], a.count(a[0]), a.count(a[-1]))
if a[0] == a[-1]:
	ways = nCr(way1, 2)
else:
	ways = way1 * way2
print(ma, ways)


n = int(input())
l = list(map(int, input().split(' ')))
a = max(l)
b = min(l)
print(a - b)
c = l.count(a)
d = l.count(b)
if a == b:
	print(int(c * (c + 1) / 2 - c))
else:
	print(c * d)


n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[0] == a[-1]:
	c = len(a) * (len(a) - 1) // 2
else:
	c = a.count(a[0]) * a.count(a[-1])
print(a[-1] - a[0], c)


import sys
n = int(sys.stdin.readline().strip())
arr = [int(x) for x in sys.stdin.readline().strip().split()]
arr.sort()
diff = arr[-1] - arr[0]
from collections import Counter
d = Counter(arr)
tot = 0
i = n - 1
j = 0
if diff != 0:
	while i > j:
		if arr[i] - arr[j] == diff:
			tot += d[arr[i]] * d[arr[j]]
		i -= d[arr[i]]
		j += d[arr[j]]
	print(diff, tot)
else:
	print(0, n * (n - 1) // 2)


n = int(input())
li = list(map(int, input().split()))
li.sort()
dif = li[-1] - li[0]
t1 = li.count(li[0])
t2 = li.count(li[-1])
if li[0] != li[-1]:
	print(dif, t1 * t2)
else:
	print(dif, t1 * (t1 - 1) // 2)


n = int(input())
L = list(map(int, input().split()))
s = max(L) - min(L)
if s == 0:
	a = n * (n - 1) // 2
else:
	a = L.count(max(L)) * L.count(min(L))
print(s, a)


n = int(input())
l = [int(i) for i in input().split()]
a = max(l) - min(l)
if a == 0:
	m = n * (n - 1) // 2
else:
	ca = l.count(max(l))
	ci = l.count(min(l))
	m = ca * ci
print(a, m)


from functools import reduce
from operator import mul
from fractions import Fraction

def ncr(n, r):
	return int(reduce(mul, (Fraction(n - i, i + 1) for i in range(r)), 1))
num_flowers = int(input())
beauties = list(map(int, input().split()))
max_beauty = beauties[0]
min_beauty = beauties[0]
max_beauty_occurrences = min_beauty_occurrences = 1
for beauty in beauties[1:]:
	if beauty < min_beauty:
		min_beauty = beauty
		min_beauty_occurrences = 1
	elif beauty == min_beauty:
		min_beauty_occurrences += 1
	if beauty > max_beauty:
		max_beauty = beauty
		max_beauty_occurrences = 1
	elif beauty == max_beauty:
		max_beauty_occurrences += 1
if min_beauty != max_beauty:
	print(f'{max_beauty - min_beauty} {max_beauty_occurrences * min_beauty_occurrences}')
else:
	print(f'0 {ncr(max_beauty_occurrences, 2)}')


n = int(input())
a = [int(x) for x in input().split()]
min = 1000000000
max = 1
mic = 0
mac = 0
for i in a:
	if i > max:
		max = i
		mac = 1
	elif i == max:
		mac += 1
	if i < min:
		min = i
		mic = 1
	elif i == min:
		mic += 1
if max != min:
	print(max - min, mic * mac)
else:
	print(0, int((mac * mac - mac) / 2))


n = int(input())
flowers = list(map(int, input().split()))
flowers.sort()
mx = 0
cl = 1
while cl < n and flowers[cl] == flowers[0]:
	cl += 1
cr = 1
while -1 - cr >= -n and flowers[-1 - cr] == flowers[-1]:
	cr += 1
if flowers[-1] != flowers[0]:
	print(flowers[-1] - flowers[0], cl * cr)
else:
	print(0, n * (n - 1) // 2)


n = int(input())
a = [int(x) for x in input().split()]
maxElement = 0
minElenmet = 1000000000
maxNo = 0
minNo = 0
for x in a:
	if maxElement < x:
		maxElement = x
	if minElenmet > x:
		minElenmet = x
for x in a:
	if x == maxElement:
		maxNo += 1
	if x == minElenmet:
		minNo += 1
if maxElement == minElenmet:
	answer = int(maxNo * (maxNo - 1) / 2)
else:
	answer = maxNo * minNo
differ = maxElement - minElenmet
print(differ, answer)


nb_flowers = int(input())
beauties = [int(x) for x in input().split()]
mins = min(beauties)
maxs = max(beauties)
max_beauty = maxs - mins
if mins == maxs:
	nb_ways = nb_flowers * (nb_flowers - 1) // 2
else:
	nb_ways = beauties.count(mins) * beauties.count(maxs)
print(max_beauty, nb_ways)


import operator as op
from functools import reduce

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom
n = int(input())
l = [int(x) for x in input().split()]
mn = min(l)
mx = max(l)
c1 = 0
c2 = 0
for i in range(n):
	if l[i] == mn:
		c1 += 1
	if l[i] == mx:
		c2 += 1
if mx == mn:
	a = int(ncr(c1, 2))
else:
	a = c1 * c2
print(mx - mn, a)


from math import factorial
n = int(input())
a = list(map(int, input().split()))
mn = min(a)
mx = max(a)
mn_c = a.count(mn)
mx_c = a.count(mx)
if mn != mx:
	print(mx - mn, mn_c * mx_c)
else:
	print(mx - mn, mn_c * (mn_c - 1) // 2)


import math
n = int(input())
b = list(map(int, input().split()))
b.sort()
if b[0] == b[-1]:
	ret = 0
	for i in range(1, n):
		ret += i
	print(0, ret)
else:
	i = 0
	while b[i] == b[0]:
		i += 1
	j = -1
	while b[j] == b[-1]:
		j -= 1
	print(b[-1] - b[0], i * -(j + 1))


n = int(input())
b = list(map(int, input().split()))
(p, o) = (max(b), min(b))
(q, w) = (b.count(p), b.count(o))
if p == o:
	if n != 2:
		print(0, q * (q - 1) // 2)
	else:
		print(0, 1)
else:
	print(p - o, q * w)


n = int(input())
s = list(map(int, input().split()))
(ma, mi) = (max(s), min(s))
if ma == mi:
	print(str(ma - mi) + ' ' + str(int(n * (n - 1) / 2)))
else:
	print(str(ma - mi) + ' ' + str(s.count(ma) * s.count(mi)))


def main():
	n = int(input())
	ar = [int(i) for i in input().split()]
	d = dict()
	ar.sort()
	for i in ar:
		d[i] = d.get(i, 0) + 1
	count = 0
	ma = ar[-1] - ar[0]
	for i in ar:
		if i + ma in d:
			d[i] = d[i] - 1
			count += d[i + ma]
	print(ma, count)
	return 0
main()


import sys
n = int(input())
alist = list(map(int, sys.stdin.readline().split()))
max_b = max(alist)
min_b = min(alist)
if max_b != min_b:
	nb_max = alist.count(max_b)
	nb_min = alist.count(min_b)
	print(max_b - min_b, nb_max * nb_min)
else:
	nb = alist.count(max_b)
	print(0, nb * (nb - 1) // 2)


n = int(input())
l = sorted(list(map(int, input().split())))
nr = 0
nr2 = 0
i = 0
if l[0] == l[n - 1]:
	nr = n * (n - 1) // 2
	n = n - 1
else:
	while i < n - 1 and l[0] == l[i]:
		(i, nr) = (i + 1, nr + 1)
	n -= 1
	i = n
	while i > 1 and l[n] == l[i]:
		(i, nr2) = (i - 1, nr2 + 1)
	nr = nr * nr2
	if len(l) == 2:
		nr += 1
print(l[n] - l[0], nr)


n = int(input())

def f(n):
	k = 1
	for i in range(2, n):
		k += i
	return k
l = sorted(map(int, input().split()))
if len(set(l)) == 1:
	print(0, f(n))
else:
	print(l[-1] - l[0], l.count(l[0]) * l.count(l[-1]))


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
d = Counter(l)
(a, b) = (min(l), max(l))
print(b - a, n * (n - 1) // 2 if b - a == 0 else d[a] * d[b])


import operator as op
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import reduce
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom
n = inp()
a = inlist()
mn = min(a)
mx = max(a)
mnC = a.count(mn)
mxC = a.count(mx)
res = mnC * mxC
if mn == mx:
	res = ncr(mnC, 2)
print(mx - mn, res)


from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
mn = min(arr)
mx = max(arr)
mxd = mx - mn
dct = Counter(arr)
c = 0
for x in arr:
	if x + mxd in dct:
		c += dct[x + mxd]
print(mxd, c if mxd else n * (n - 1) // 2)


n = int(input())
l = list(map(int, input().split()))
s = set(l)
ml = list(s)
ml.sort()
f = ml[-1] - ml[0]
j = len(ml) - 1
c = 0
d = {}
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
i = 0
while i < j:
	if ml[j] - ml[i] == f:
		c += d[ml[j]] * d[ml[i]]
		i += 1
	elif l[j] - l[i] > f:
		j += 1
	else:
		i += 1
if f == 0:
	c = max(d.values())
	c = c * (c - 1) // 2
print(f, c)


def alldist(lst, n):
	it = lst[0]
	for i in lst:
		if i != it:
			return False
	return True
n = int(input())
lst = [int(x) for x in input().split()]
lst.sort()
maxdif = lst[n - 1] - lst[0]
a = 0
b = 0
c = max(lst)
d = min(lst)
for i in lst:
	if i == c:
		a += 1
	if i == d:
		b += 1
if alldist(lst, n):
	if len(lst) == 2:
		print(maxdif, 1)
	else:
		print(maxdif, int(n / 2 * (n - 1)))
else:
	print(maxdif, a * b)


import math
import sys
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = prime[1] = False
	r = [p for p in range(n + 1) if prime[p]]
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))
n = ii()
d = li()
max = cmin = cmax = 0
min = 10 ** 9 + 1
for i in d:
	if i == min:
		cmin += 1
	elif i < min:
		min = i
		cmin = 1
	if i == max:
		cmax += 1
	elif i > max:
		max = i
		cmax = 1
print(max - min, cmax * cmin if min != max else cmin * (cmin - 1) // 2)


n = int(input())
l = list(map(int, input().split()))
l.sort()
d = l[n - 1] - l[0]
if d == 0:
	now = n * (n - 1) // 2
	print(0, now)
	exit()
n1 = l.count(l[0])
n2 = l.count(l[n - 1])
now = n1 * n2
print(d, now)


n = int(input())
b = [int(i) for i in input().split()]
minimal = min(b)
maximal = max(b)
firstValue = maximal - minimal
if firstValue == 0:
	secondValue = len(b) * (len(b) - 1) // 2
else:
	secondValue = b.count(maximal) * b.count(minimal)
print(firstValue, secondValue)


n = int(input())
a = list(map(int, input().split()))
maximum = max(a)
minimum = min(a)
if minimum == maximum:
	print(0, int(n / 2 * (n - 1)))
else:
	print(maximum - minimum, a.count(maximum) * a.count(minimum))


n = int(input())
l = list(map(int, input().strip().split()))
leastcount = l.count(min(l))
maxcount = l.count(max(l))
if min(l) == max(l):
	print(0, maxcount * (maxcount - 1) // 2)
else:
	print(max(l) - min(l), leastcount * maxcount)


n = int(input())
a = list(map(int, input().split(' ')))
a.sort()
fa = a[n - 1] - a[0]
fm = 0
lm = 0
for i in range(0, n):
	if a[i] == a[0]:
		fm += 1
	elif a[i] == a[n - 1]:
		lm += 1
a2 = fm * lm
if fm == 0 or lm == 0:
	a2 = fm + lm
	a2 = int(a2 * (a2 - 1) / 2)
print(fa, a2)


def sum_seq(x):
	ans = 0
	for i in range(1, len(x)):
		ans += i
	return ans
n = int(input())
x = sorted(list(map(int, input().split())))
if len(set(x)) != 1:
	print(x[-1] - x[0], x.count(x[-1]) * x.count(x[0]))
else:
	print(x[-1] - x[0], sum_seq(x))


n = int(input())
beauties = [int(i) for i in input().split()]
beauties = sorted(beauties)
if beauties[-1] - beauties[0] == 0:
	print(0, int(n * (n - 1) / 2))
else:
	count1 = 1
	for i in range(1, len(beauties)):
		if beauties[i] == beauties[0]:
			count1 += 1
		else:
			break
	count2 = 1
	for i in range(-2, -len(beauties) - 1, -1):
		if beauties[i] == beauties[-1]:
			count2 += 1
		else:
			break
	print(beauties[-1] - beauties[0], count1 * count2)


import operator as op
from functools import reduce

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom
n = int(input())
a = list(map(int, input().split()))
a.sort()
(b, c) = (a[0], a[n - 1])
print(c - b, end=' ')
if b != c:
	(b, c) = (a.count(b), a.count(c))
	print(b * c)
else:
	b = a.count(b)
	print(int(ncr(b, 2)))


n = int(input())
b = list(map(int, input().split()))
b.sort()
if len(set(b)) == 1:
	print('0', n * (n - 1) // 2)
elif len(b) == 2:
	print(abs(b[1] - b[0]), 1)
else:
	temp = b.count(b[-1])
	temp1 = b.count(b[0])
	print(b[-1] - b[0], temp * temp1)


n = int(input())
a = input().split(' ')
ca = 0
cb = 0
MAX = 0
MIN = 10000000000
for data in a:
	x = int(data)
	if x < MIN:
		cb = 1
		MIN = x
	elif x == MIN:
		cb += 1
	if x > MAX:
		MAX = x
		ca = 1
	elif x == MAX:
		ca += 1
if ca == n:
	print(MAX - MIN, ' ', n * (n - 1) >> 1)
else:
	print(MAX - MIN, ' ', ca * cb)


from sys import stdin, stdout
input = stdin.readline
n = int(input())
b = sorted(list(map(int, input().split())))
ma = b[n - 1] - b[0]
cnt1 = cnt2 = 0
if ma == 0:
	stdout.write('0 ' + str(n * (n - 1) // 2))
	exit(0)
for i in b:
	if i == b[0]:
		cnt1 += 1
	else:
		break
for i in b[::-1]:
	if i == b[n - 1]:
		cnt2 += 1
	else:
		break
stdout.write(str(ma) + ' ' + str(cnt1 * cnt2))


R = lambda : map(int, input().split())
n = input()
a = list(R())
min_ = min(a)
max_ = max(a)
d = max_ - min_
if min_ != max_:
	c = a.count(min_) * a.count(max_)
else:
	c = a.count(min_)
	c *= c - 1
	c //= 2
print(d, c)


lst = list(map(int, input().split()))
n = lst[0]
b = list(map(int, input().split()))
max = -1
min = 10000000000
maxf = 0
minf = 0
for x in b:
	if x > max:
		maxf = 1
		max = x
	elif x == max:
		maxf += 1
	if x < min:
		minf = 1
		min = x
	elif x == min:
		minf += 1
if max == min:
	print(max - min, maxf * (maxf - 1) // 2)
else:
	print(max - min, maxf * minf)


from math import *
n = int(input())
a = list(map(int, input().split()))
k = max(a) - min(a)
x = a.count(max(a))
y = a.count(min(a))
if max(a) != min(a):
	print(str(k) + ' ' + str(x * y))
else:
	print(str(0) + ' ' + str(n * (n - 1) // 2))


n = int(input())
a = list(map(int, input().split()))
a.sort()
k = a[len(a) - 1] - a[0]
if a[0] != a[len(a) - 1]:
	print(k, a.count(a[0]) * a.count(a[len(a) - 1]))
else:
	d = a.count(a[0])
	print(k, d * (d - 1) // 2)


n = int(input())
A = [int(x) for x in input().split()]
(a, b) = (min(A), max(A))
(m, n) = (A.count(a), A.count(b))
if a == b:
	print(0, n * (n - 1) // 2)
else:
	print(b - a, m * n)


x = int(input())
a = list(map(int, input().split()))
a.sort()
b = a[0]
c = a[x - 1]
d = 0
e = 0
if b != c:
	for i in a:
		if i == b:
			d += 1
		if i == c:
			e += 1
	print(c - b, d * e)
else:
	print(0, x * (x - 1) // 2)


from collections import defaultdict, Counter
import math
n = int(input())
arr = list(map(int, input().split()))
maxx = max(arr)
minn = min(arr)
diff = maxx - minn
c = Counter(arr)
if c[maxx] == c[minn] == n:
	print(diff, math.ceil(n * ((n - 1) / 2)))
else:
	print(diff, c[maxx] * c[minn])


import sys

def solve(input_path=None):
	if input_path is None:
		f = sys.stdin
	else:
		f = open(input_path, 'r')
	n = int(f.readline())
	height = list(map(int, f.readline().split()))
	min_height = min(height)
	max_height = max(height)
	if min_height == max_height:
		return [f'{max_height - min_height} {n * (n - 1) // 2}']
	num_min = 0
	num_max = 0
	for h in height:
		if h == min_height:
			num_min += 1
		if h == max_height:
			num_max += 1
	return [f'{max_height - min_height} {num_min * num_max}']

def main():
	for line in solve():
		print(f'{line}')
main()


from collections import Counter

def lo(y, a):
	if y < a:
		return y
	else:
		return a

def sp(t):
	return t * (t - 1) // 2
yuxi = -1
lowe = 1000000002
las = Counter({})
useless = input()
for i in input().split():
	g = int(i)
	yuxi = max(yuxi, g)
	lowe = lo(lowe, g)
	las[g] += 1
if lowe == yuxi:
	print(0, sp(las[lowe]))
else:
	print(yuxi - lowe, las[yuxi] * las[lowe])


(n, l1) = (int(input()), list(map(int, input().split())))
(max1, min1) = (max(l1), min(l1))
(count1, count2) = (l1.count(max1), l1.count(min1))
if max1 == min1:
	print(0, n * (n - 1) // 2)
else:
	print(max1 - min1, count1 * count2)


x = int(input())
a = list(map(int, input().split()))
print(max(a) - min(a), end=' ')
if max(a) == min(a):
	print((x - 1) * x // 2)
else:
	print(a.count(max(a)) * a.count(min(a)))


import sys
from collections import defaultdict
f = sys.stdin
f.readline()
a = list(map(int, f.readline().split()))
a.sort()
n = len(a)
if a[0] != a[-1]:
	print(a[-1] - a[0], a.count(a[0]) * a.count(a[-1]))
else:
	print(0, n * (n - 1) // 2)


from collections import Counter
t = int(input())
x = list(map(int, input().split()))
x.sort()
if x[0] == x[-1]:
	print(0, end=' ')
	print(t * (t - 1) // 2)
else:
	p = dict(Counter(x))
	z = list(p.values())
	print(abs(x[0] - x[-1]), end=' ')
	print(z[0] * z[-1])


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
diff = arr[n - 1] - arr[0]
if len(set(arr)) > 1:
	print(diff, arr.count(min(arr)) * arr.count(max(arr)))
else:
	print(diff, n * (n - 1) // 2)


def count_flowers(flowers):
	flowers.sort()
	if flowers[0] == flowers[-1]:
		l = len(flowers)
		return (0, int(l * (l - 1) / 2))
	left_part = right_part = 1
	while flowers[left_part] == flowers[0]:
		left_part += 1
	while flowers[-1 - right_part] == flowers[-1]:
		right_part += 1
	return (flowers[-1] - flowers[0], left_part * right_part)
_ = input()
flowers = [int(flower) for flower in input().split()]
(max_diff, count) = count_flowers(flowers)
print(f'{max_diff} {count}', sep='')


n = int(input())
li = [int(x) for x in input().split()]
li.sort()
diff = li[-1] - li[0]
min_count = li.count(li[0])
max_count = li.count(li[-1])
if diff == 0:
	count = (min_count - 1) * min_count // 2
else:
	count = min_count * max_count
print(diff, count)


x = int(input())
s = input()
l = [int(n) for n in s.split()]
l.sort()
count = 0
m = l[-1] - l[0]
a = l.count(l[0])
b = l.count(l[-1])
if l[-1] != l[0]:
	print('{} {}'.format(m, a * b))
else:
	n = (x - 1) * x
	print('{} {}'.format(m, n // 2))


n = int(input())
m = [int(i) for i in input().split()]
ugliest = min(m)
prettiest = max(m)
ugly = m.count(ugliest)
pretty = m.count(prettiest)
print(prettiest - ugliest, ugly * pretty if ugliest != prettiest else pretty * (pretty - 1) // 2)


n = int(input())
b = [int(i) for i in input().split()]
b.sort()
ma = b[-1] - b[0]
if b[-1] != b[0]:
	mi = int(b.count(b[0]) * b.count(b[-1]))
else:
	mi = int(b.count(b[0]) * (b.count(b[0]) - 1) / 2)
print(ma, mi)


n = int(input())
a = list(map(int, input().split()))
a.sort()
c = 1
for i in range(n - 1):
	if a[i] == a[i + 1]:
		c += 1
	else:
		break
if c == n:
	print(a[-1] - a[0], c * (c - 1) // 2)
else:
	d = 1
	for i in range(n - 1, 0, -1):
		if a[i] == a[i - 1]:
			d += 1
		else:
			break
	print(a[-1] - a[0], d * c)


n = int(input())
x = list(map(int, input().split()))
x.sort()
a = 0
b = 0
for i in range(n - 1):
	if x[0] == x[i + 1]:
		a = a + 1
for c in range(n - 1):
	if x[n - 1] == x[c]:
		b = b + 1
if n == 2:
	print(x[n - 1] - x[0], 1)
elif x[n - 1] == x[0]:
	print(x[n - 1] - x[0], int(n * (n - 1) / 2))
else:
	print(x[n - 1] - x[0], (a + 1) * (b + 1))


def main():
	n = int(input())
	tab = list(map(int, input().split()))
	tab.sort()
	maxd = tab[-1] - tab[0]
	co = 0
	mi = 0
	ma = 0
	for x in range(n):
		if tab[x] == tab[0]:
			mi += 1
		if tab[x] == tab[-1]:
			ma += 1
	if tab[0] == tab[-1]:
		print(0, n * (n - 1) // 2)
	else:
		print(maxd, ma * mi)
main()


n = int(input())
lis = list(map(int, input().split()))
lis = list(sorted(lis))
c = 0
diff = lis[n - 1] - lis[0]
r = lis.count(lis[0])
p = lis.count(lis[-1])
if lis[0] == lis[-1]:
	print(0, r * (r - 1) // 2)
else:
	print(diff, r * p)


n = int(input())
l = [int(s) for s in input().split()]
d = {}
a = max(l)
b = min(l)
for i in l:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
if a != b:
	print(a - b, d[a] * d[b])
else:
	print(0, d[a] * (d[a] - 1) // 2)


import collections
from math import factorial
input()
dic = collections.Counter(map(int, input().split()))
if len(dic) == 1:
	n = dic[list(dic.keys())[0]]
	print(0, n * (n - 1) // 2)
else:
	(max_dic, min_dic) = (max(dic), min(dic))
	print(max_dic - min_dic, dic[max_dic] * dic[min_dic])


n = int(input())
ar = sorted(list(map(int, input().split())))
ans = 0
val = 0
ans = ar[-1] - ar[0]
if len(set(ar)) == 1:
	val = n * (n - 1) // 2
else:
	val = ar.count(ar[0]) * ar.count(ar[-1])
print(ans, val)


n = int(input())
list1 = list(map(int, input().split()))
min1 = min(list1)
max1 = max(list1)
num1 = list1.count(min1)
num2 = list1.count(max1)
if max1 != min1:
	print(max1 - min1, num1 * num2)
else:
	print(0, num1 * (num1 - 1) // 2)


import math
n = int(input())
ls = [int(x) for x in input().split()]
ma = max(ls)
mi = min(ls)
nma = ls.count(ma)
nmi = ls.count(mi)
diff = ma - mi
ways = nma * nmi
if diff == 0:
	ways = sum(range(nma))
print(diff, int(ways))


n = int(input())
flores = list(map(int, input().split()))
flores.sort()
maxDiff = flores[n - 1] - flores[0]
if flores[0] == flores[n - 1]:
	print(str(maxDiff) + ' ' + str(int(n * (n - 1) / 2)))
else:
	timesMin = flores.count(flores[0])
	timesMax = flores.count(flores[n - 1])
	print(str(maxDiff) + ' ' + str(timesMax * timesMin))


n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
mini = min(a)
maxi = max(a)
for i in range(n):
	if a[i] == maxi:
		x += 1
	if a[i] == mini:
		y += 1
if maxi != mini:
	print(maxi - mini, x * y)
else:
	print(0, n * (n - 1) // 2)


n = int(input())
b = [int(x) for x in input().split()]
maxi = max(b)
mini = min(b)
if maxi == mini:
	ans = n * (n - 1) // 2
	print(0, ans)
else:
	print(maxi - mini, b.count(maxi) * b.count(mini))


n = int(input())
a = list(map(int, input().split()))
x = min(a)
y = max(a)
c1 = a.count(x)
c2 = a.count(y)
if x == y:
	print(y - x, c1 * (c1 - 1) // 2)
	exit()
print(y - x, c1 * c2)


from collections import Counter
n = int(input())
b = list(map(int, input().split()))
c = Counter(b)
M = max(c.keys())
m = min(c.keys())
print(M - m, int(m != M) * c[M] * c[m] + int(m == M) * (c[m] * (c[m] - 1)) // 2)


n = int(input())
lis = sorted([int(x) for x in input().split()])
print(lis[-1] - lis[0], lis.count(lis[-1]) * lis.count(lis[0]) if lis[-1] != lis[0] else n * (n - 1) // 2)


n = int(input())
array = [int(x) for x in input().split()]
Max = array[0]
Min = array[0]
count_max = 1
count_min = 1
for i in range(1, n):
	if array[i] > Max:
		count_max = 1
		Max = array[i]
	elif array[i] < Min:
		count_min = 1
		Min = array[i]
	elif array[i] == Min:
		count_min += 1
		if Min == Max:
			count_max += 1
	elif array[i] == Max:
		count_max += 1
if Min == Max:
	print(*[0, int(count_min * ((count_min - 1) / 2))], sep=' ')
else:
	print(*[Max - Min, count_min * count_max], sep=' ')


import math
n = int(input())
b = list(sorted(map(int, input().split())))
if b[-1] != b[0]:
	cnt = b.count(b[0]) * b.count(b[-1])
else:
	cnt = n * (n - 1) // 2
print(b[-1] - b[0], cnt)


n = int(input())
a = [*map(int, input().split())]
big = max(a)
small = min(a)
numbig = 0
numsmall = 0
for i in a:
	if i == big:
		numbig += 1
	if i == small:
		numsmall += 1
print(big - small, numbig * numsmall if big != small else numbig * (numbig - 1) // 2)


n = int(input())
inp = input()
l = [int(x) for x in inp.split()]
max = max(l)
min = min(l)
if max == min:
	print(0, (n ** 2 - n) // 2)
else:
	print(max - min, l.count(max) * l.count(min))


ans = int(input())
list1 = sorted(map(int, input().split()))
ans2 = list1[-1] - list1[0]
c = 0
if list1[-1] == list1[0]:
	c = ans * (ans - 1) // 2
else:
	c = list1.count(list1[-1]) * list1.count(list1[0])
print(ans2, c)


n = int(input())
arr = [int(x) for x in input().split()]
set1 = set(arr)
max1 = max(arr)
min1 = min(arr)
max_diff = max1 - min1
if len(set1) == 1:
	print(max_diff, end=' ')
	print(n * (n - 1) // 2)
	exit(0)
c1 = 0
c2 = 0
for ele in arr:
	if ele == max1:
		c1 += 1
	if ele == min1:
		c2 += 1
print(max_diff, c1 * c2)


import math
n = int(input())
a = list(map(int, input().split()))
menor = min(a)
mayor = max(a)
resta = mayor - menor
if mayor == menor:
	res2 = n * (n - 1) / 2
	print(resta, int(res2))
else:
	print(mayor - menor, a.count(menor) * a.count(mayor))


def main():
	n = int(input())
	b = sorted(list(map(int, input().split())))
	if b[0] == b[n - 1]:
		n = n - 1
		print(0, round(n * (n + 1) / 2))
	else:
		c = b.count(b[0])
		d = b.count(b[n - 1])
		print(b[n - 1] - b[0], c * d)
main()


a = list()
n = int(input())
l = list(map(int, input().split()))
l.sort()
f = l[len(l) - 1] - l[0]
count = 0
sum = 0
for i in range(0, len(l), 1):
	if l[i] == l[0]:
		count += 1
	if l[i] == l[len(l) - 1]:
		sum += 1
if l[0] == l[len(l) - 1]:
	print(f, n * (n - 1) // 2)
else:
	print(f, count * sum)


n = int(input())
a = sorted(map(int, input().split()))
if a[0] == a[-1]:
	print(0, n * (n - 1) // 2)
else:
	(b, c) = (1, 1)
	for i in range(1, n):
		if a[i] == a[0]:
			b += 1
		if a[-(i + 1)] == a[-1]:
			c += 1
	print(a[-1] - a[0], b * c)


n = int(input())
a = list(map(int, input().split()))
b = max(a)
c = min(a)
d = b - c
e = a.count(b)
f = a.count(c)
if b == c:
	j = 0
	for i in range(n):
		j += i
	print(0, j)
else:
	print(d, e * f)


tcs = int(input())
b = list(map(int, input().split(' ')))
up = max(b)
down = min(b)
if up != down:
	diff = abs(up - down)
	ctmx = b.count(up)
	ctmn = b.count(down)
	print(diff, ctmx * ctmn)
else:
	print(0, int(tcs * (tcs - 1) / 2))


from math import factorial as f
n = int(input())
a = list(map(int, input().split()))
x = max(a) - min(a)
p = a.count(max(a))
q = a.count(min(a))
if x == 0:
	y = n * (n - 1) // 2
else:
	y = p * q
print(x, y)


n = int(input())
b = input().split()
b = [int(i) for i in b]
min_b = min(b[0], b[1])
max_b = max(b[0], b[1])
for i in b:
	if i < min_b:
		min_b = i
	if i > max_b:
		max_b = i
count_min = 0
count_max = 0
for i in b:
	if i == min_b:
		count_min += 1
	if i == max_b:
		count_max += 1
if min_b == max_b:
	print(0, count_min * (count_min - 1) // 2)
else:
	print(max_b - min_b, count_max * count_min)


input()
arr = list(map(int, input().strip().split()))
(a, b) = (min(arr), max(arr))
d = b - a
if a == b:
	n = arr.count(a)
	n = int(n * (n - 1) / 2)
else:
	n = arr.count(a) * arr.count(b)
print(d, n)


n = int(input())
arr = [int(x) for x in input().split()]
maxim = max(arr)
minim = min(arr)
d = maxim - minim
a = arr.count(maxim)
b = arr.count(minim)
if a == n:
	print(d, a * (a - 1) // 2)
else:
	way = a * b
	print(d, way)


n = int(input())
b = sorted(map(int, input().split()))
(h, l) = (b[-1], b[0])
c = n * (n - 1) // 2 if h == l else b.count(h) * b.count(l)
print(h - l, c)


m = int(input())
s = sorted(map(int, input().split()))
print(s[-1] - s[0], s.count(s[0]) * s.count(s[-1]) if s[0] != s[-1] else m * (m - 1) // 2)


n = int(input())
cicekler = list(map(int, input().split()))
enAzGuzelCicek = 10 ** 9
enGuzelCicek = 0
enAzGuzelCicekSayisi = 1
enGuzelCicekSayisi = 1
for cicek in cicekler:
	if cicek < enAzGuzelCicek:
		enAzGuzelCicek = cicek
		enAzGuzelCicekSayisi = 1
	elif cicek == enAzGuzelCicek:
		enAzGuzelCicekSayisi += 1
	if cicek > enGuzelCicek:
		enGuzelCicek = cicek
		enGuzelCicekSayisi = 1
	elif cicek == enGuzelCicek:
		enGuzelCicekSayisi += 1
maksimumGuzellikFarki = enGuzelCicek - enAzGuzelCicek
ihtimalSayisi = enGuzelCicekSayisi * enAzGuzelCicekSayisi
if enGuzelCicekSayisi == n:
	ihtimalSayisi = int(n * (n - 1) / 2)
else:
	ihtimalSayisi = enGuzelCicekSayisi * enAzGuzelCicekSayisi
print(maksimumGuzellikFarki, ihtimalSayisi)


n = int(input())
a = sorted(map(int, input().split()))
print(a[-1] - a[0], (a.count(a[-1]) * a.count(a[0]), n * (n - 1) // 2)[a[-1] == a[0]])


n = int(input())
f = list(map(int, input().split()))
f.sort()
print(f[n - 1] - f[0], end=' ')
a = f.count(f[n - 1])
b = f.count(f[0])
if f[n - 1] == f[0]:
	print(b * (b - 1) // 2)
else:
	print(a * b)


mn = 10 ** 10
mx = 0
mnc = mxc = 1
input()
for i in map(int, input().split()):
	if i < mn:
		mn = i
		mnc = 1
	elif i == mn:
		mnc += 1
	if i > mx:
		mx = i
		mxc = 1
	elif i == mx:
		mxc += 1
if mx == mn:
	print(0, mxc * (mxc - 1) // 2)
else:
	print(mx - mn, mxc * mnc)


a = int(input())
l = input().split()
p = []
for i in range(a):
	p.append(int(l[i]))
p.sort()
b = p[-1]
c = p[0]
d = p.count(b)
e = p.count(c)
if b == c:
	g = d * (d - 1) // 2
	print(0, g)
else:
	t = b - c
	q = d * e
	print(t, q)


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
from collections import Counter
nb_flower = read_int()
flowers = Counter(read_ints())
(maxf, minf) = (max(flowers), min(flowers))
res1 = maxf - minf
res2 = flowers[maxf] * flowers[minf] if res1 else flowers[maxf] * (flowers[maxf] - 1) // 2
print(res1, res2)


def fact(x):
	if x == 1:
		return 1
	cal = 0
	for i in range(1, x):
		cal += i
	return cal
n = int(input().strip())
a = [int(x) for x in input().strip().split()]
(p, q) = (max(a), min(a))
(r, s) = (sum([1 for x in a if x == p]), sum([1 for x in a if x == q]))
if p != q:
	print(p - q, r * s)
else:
	print(p - q, fact(r))


n = int(input())
b = [int(x) for x in input().split()]
b.sort(reverse=True)
pos = 1
maxi = 1
for i in range(len(b) - 1):
	if b[i] == b[i + 1]:
		pos += 1
	else:
		break
for i in range(len(b) - 1):
	if b[n - 1 - i] == b[n - 2 - i]:
		maxi += 1
	else:
		break
if b[0] == b[n - 1]:
	print(0, int(n * (n - 1) / 2))
else:
	print(b[0] - b[n - 1], pos * maxi)


n = int(input())
a = sorted(list(map(int, input().split())))
if len(set(a)) > 1:
	print(str(a[-1] - a[0]) + ' ' + str(a.count(a[0]) * a.count(a[-1])))
elif len(set(a)) == 1:
	print(str(0) + ' ' + str(n * (n - 1) // 2))


n = int(input())
b = [int(x) for x in input().split()]
dif = max(b) - min(b)
if dif != 0:
	ways = b.count(max(b)) * b.count(min(b))
else:
	ways = len(b) * (len(b) - 1) // 2
print(str(dif) + ' ' + str(ways))


n = int(input())
lista = list(map(int, input().split()))
mi = min(lista)
ma = max(lista)
if ma == mi:
	print(ma - mi, int((n - 1) * n / 2))
else:
	print(ma - mi, lista.count(ma) * lista.count(mi))


n = int(input())
b_list = list(map(int, input().split()))
maxx = max(b_list)
minn = min(b_list)
if maxx != minn:
	count = b_list.count(maxx) * b_list.count(minn)
else:
	count = int(n * (n - 1) / 2)
print(maxx - minn, count)


n = int(input())
List = list(map(int, input().split()))
ma = max(List)
mi = min(List)
if ma == mi:
	print(0, List.count(ma) * (List.count(mi) - 1) // 2)
	exit()
print(ma - mi, List.count(ma) * List.count(mi))


from collections import Counter
testcase = int(input())
li = [int(x) for x in input().split()]
li.sort()
max_dif = li[-1] - li[0]
count = Counter(li)
if len(count) != 1:
	print(max_dif, count[li[-1]] * count[li[0]])
else:
	print(max_dif, count[li[0]] * (count[li[0]] - 1) // 2)


n = int(input())
b = sorted(map(int, input().split()))
if b[-1] - b[0]:
	i = 1
	while i < n and b[i] == b[0]:
		i += 1
	min_cnt = i
	i = n - 2
	while i > 0 and b[i] == b[-1]:
		i -= 1
	max_cnt = n - 1 - i
	print(b[-1] - b[0], min_cnt * max_cnt)
else:
	print(0, n * (n - 1) // 2)


def flower():
	k = int(input())
	c = list(map(int, input().split(' ')))
	(i, j) = (max(c), min(c))
	p = i - j
	print(p, [k * (k - 1) // 2, c.count(i) * c.count(j)][i != j])
flower()


n = int(input())
a = list(map(int, input().split()))
s = set(a)
mx = max(a)
mn = min(a)
mxc = a.count(mx)
mnc = a.count(mn)
print(mx - mn, n * (n - 1) // 2 if len(s) == 1 else mxc * mnc)


n = int(input())
l = [int(i) for i in input().split()]
l.sort()
mx = max(l)
mi = min(l)
num1 = l.count(mx)
num2 = l.count(mi)
ans1 = mx - mi
ans2 = num1 * num2
if mx == mi:
	ans2 = int(num1 * (num1 - 1) / 2)
print(ans1, ans2)


n = int(input())
arr = list(map(int, input().split()))
m = max(arr)
l = min(arr)
f = arr.count(m)
s = arr.count(l)
if m != l:
	print(m - l, f * s)
else:
	print(m - l, n * (n - 1) // 2)


import math, fractions
n = int(input())
q = [int(x) for x in input().split()]
xq = max(q)
nq = min(q)
dif = xq - nq
if xq == nq:
	qc = q.count(xq)
	c = qc * (qc - 1) // 2
else:
	c = q.count(xq) * q.count(nq)
print(dif, c)


n = int(input())
lijst = list(map(int, input().split(' ')))
verschil = 0
aantalKlein = 1
aantalGroot = 1
orde = sorted(lijst)
verschil = orde[n - 1] - orde[0]
klein = orde[0]
teller = 1
while orde[teller] == klein and teller < n - 1:
	aantalKlein += 1
	teller += 1
groot = orde[n - 1]
teller = n - 2
while orde[teller] == groot and teller >= 0:
	aantalGroot += 1
	teller -= 1
if verschil == 0:
	mogelijkheden = 0
	for i in range(1, n):
		mogelijkheden += i
	print(verschil, mogelijkheden)
else:
	print(verschil, aantalKlein * aantalGroot)


n = int(input())
a = list(map(int, input().split()))
a.sort()
f = a.count(a[0])
s = a.count(a[n - 1])
if f == n:
	print(0, n * (n - 1) // 2)
else:
	print(a[n - 1] - a[0], s * f)


t = int(input())
numbers = list(map(int, input().split()))
numbers.sort()
N = len(numbers) - 1
minVal = numbers[0]
maxVal = numbers[N]
countmin = 1
countmax = 1
i = 1
while numbers[i] == minVal:
	countmin += 1
	i += 1
	if i == N + 1:
		break
i = N - 1
while numbers[i] == maxVal:
	countmax += 1
	i -= 1
	if i == -1:
		break
if minVal == maxVal:
	print('0', int((N + 1) * N / 2))
else:
	print(maxVal - minVal, countmax * countmin)


n = int(input())
l = list(map(int, input().split()))
l.sort()
xs = min(l)
ys = max(l)
mi = ma = 0
for i in l:
	if i == xs:
		mi += 1
	elif i == ys:
		ma += 1
print(ys - xs, end=' ')
if xs == ys:
	print(mi * (mi - 1) // 2)
else:
	print(ma * mi)


n = int(input())
z = list(map(int, input().split()))
p = max(z) - min(z)
l = z.count(max(z))
m = z.count(min(z))
if len(set(z)) == 1:
	print(p, n * (n - 1) // 2)
else:
	print(p, l * m)


def _c(n):
	c = 0
	for i in range(n):
		c += i
	return c
n = int(input())
a = list(map(int, input().split()))
ma = max(a)
mi = min(a)
ci = ca = 0
if mi == ma:
	print(0, _c(n))
	exit(0)
for i in a:
	if i == ma:
		ca += 1
	elif i == mi:
		ci += 1
print(ma - mi, ci * ca)


import math
n = int(input())
b = list(map(int, input().split()))
print(max(b) - min(b), b.count(max(b)) * b.count(min(b)) if max(b) != min(b) else b.count(min(b)) * (b.count(min(b)) - 1) // 2)


def fact(a):
	s = 0
	for i in range(a):
		s += i
	return s
n = input()
a = [int(s) for s in input().split()]
print(max(a) - min(a), end=' ')
mi = a.count(min(a))
ma = a.count(max(a))
if max(a) == min(a) and ma == mi:
	print(fact(ma))
else:
	print(ma * mi)


n = int(input())
ls = input().split()
ls = [int(i) for i in ls]
a = max(ls) - min(ls)
b = ls.count(max(ls)) * ls.count(min(ls))
if a == 0:
	b = int((n * n - n) / 2)
print(a, b)


n = int(input())
b = list(map(int, input().split(' ')))
(bmin, bmax) = (int(1000000000.0), 1)
d = dict()
for v in b:
	d[v] = d.get(v, 0) + 1
	if v < bmin:
		bmin = v
	if v > bmax:
		bmax = v
print(bmax - bmin, n * (n - 1) // 2 if bmin == bmax else d[bmin] * d[bmax])


t = int(input())
a = sorted(list(map(int, input().split())))
m = max(a)
n = min(a)
c = 0
for j in range(len(a) - 1, 0, -1):
	if a[j] - a[0] == m - n:
		c += 1
one = a.count(a[0]) - 1
if one == c:
	print(m - n, t * (t - 1) // 2)
else:
	print(m - n, c + one * c)


def R():
	return map(int, input().split())

def I():
	return int(input())

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
from itertools import permutations
import bisect
mod = 10 ** 9 + 7
n = I()
a = L()
M = max(a)
m = min(a)
cntM = a.count(M)
cntm = a.count(m)
if m != M:
	print(M - m, cntm * cntM)
else:
	print('0', n * (n - 1) // 2)


n = int(input())
b = list(map(int, input().split()))
diff = max(b) - min(b)
temp = b.count(max(b))
temp2 = b.count(min(b))
if max(b) != min(b):
	print(diff, temp * temp2)
else:
	print(diff, temp * (temp - 1) // 2)


n = int(input())
arr = list(map(int, input().split()))
minimum = min(arr)
i = 0
j = 0
maximum = max(arr)
for x in arr:
	if x == minimum:
		i += 1
	if x == maximum:
		j += 1
if maximum == minimum:
	print('0', (n - 1) * n // 2)
else:
	t = i * j
	print(maximum - minimum, t)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	c = collections.Counter(LI())
	ma = max(c.keys())
	mi = min(c.keys())
	if ma == mi:
		return '0 {}'.format(n * (n - 1) // 2)
	return '{} {}'.format(ma - mi, c[ma] * c[mi])
print(main())


import math
n = int(input())
f = []
g = map(int, input().split())
f = list(g)
s = 0
f.sort()
l = len(f)
f.reverse()
m = f[0] - f[l - 1]
i = 0
j = l - 1
c = 0
mx = f[0]
mn = f[l - 1]
z = f.count(mx)
x = f.count(mn)
s = z * x
root = 0
if mx == mn:
	root = math.sqrt(s)
	final = int(root * (root - 1) / 2)
else:
	final = s
print(m, final)


import operator as op
from functools import reduce

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom
n = int(input())
A = [int(i) for i in input().split()]
A.sort()
maxdiff = A[-1] - A[0]
(sm, lg) = (1, 1)
for i in range(1, n):
	if A[i] == A[0]:
		sm += 1
	else:
		break
for i in reversed(range(0, n - 1)):
	if A[i] == A[-1]:
		lg += 1
	else:
		break
if A[0] != A[-1]:
	comb = sm * lg
else:
	comb = int(ncr(sm, 2))
print(maxdiff, comb)


n = int(input())
a = list(map(int, input().split()))
(i, j) = (min(a), max(a))
if i == j:
	print(0, n * (n - 1) // 2)
else:
	print(j - i, a.count(i) * a.count(j))


n = list(input())
arr = list(map(int, input().split()))
mini = min(arr)
maxi = max(arr)
minCT = arr.count(mini)
maxCT = arr.count(maxi)
if mini == maxi:
	print(maxi - mini, ' ', maxCT * (minCT - 1) // 2)
else:
	print(maxi - mini, ' ', maxCT * minCT)


n = int(input())
arr = list(map(int, input().split()))
mn = float('inf')
mx = 0
for i in arr:
	mx = max(mx, i)
	mn = min(mn, i)
t1 = 0
t2 = 0
for i in arr:
	if i == mx:
		t1 += 1
	if i == mn:
		t2 += 1
if mn == mx:
	ans = n * (n - 1) // 2
else:
	ans = t1 * t2
print(mx - mn, end=' ')
print(ans)


n = int(input())
beauty = [int(c) for c in input().split()]
_max = 0
_min = float('infinity')
for e in beauty:
	_max = max(_max, e)
	_min = min(_min, e)
nmax = nmin = 0
for e in beauty:
	if e == _max:
		nmax += 1
	if e == _min:
		nmin += 1
max_diff = _max - _min
ways = nmax * nmin if _min != _max else nmax * (nmax - 1) // 2
print(max_diff, ways)


t = int(input())
l = list(map(int, input().split()))
l.sort()
b = l.count(l[0]) * l.count(l[-1])
a = l[-1] - l[0]
if a == 0:
	c = l.count(l[0])
	print(a, c * (c - 1) // 2)
	exit()
print(a, b)


t = int(input())
arr = [int(x) for x in input().split()]
M = max(arr)
m = min(arr)
cM = arr.count(M)
cm = arr.count(m)
print(M - m, cM * cm if M != m else t * (t - 1) // 2)


n = int(input())
m = list(map(int, input().split()))
m.sort()
w = 1
r = 1
for i in range(1, n):
	if m[i - 1] == m[i]:
		w += 1
	else:
		break
for i in range(n - 2, 0, -1):
	if m[i + 1] == m[i]:
		r += 1
	else:
		break
if m[-1] - m[0] == 0:
	print(m[-1] - m[0], w * r // 2)
else:
	print(m[-1] - m[0], w * r)


n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
dif = arr[n - 1] - arr[0]
cnt = 0
if dif == 0:
	cnt = n * (n - 1) // 2
else:
	small = 0
	big = 0
	for i in range(n):
		if arr[i] == arr[0]:
			small += 1
		else:
			break
	for i in reversed(arr):
		if i == arr[n - 1]:
			big += 1
		else:
			break
	cnt = big * small
print(str(dif) + ' ' + str(cnt))


from collections import _count_elements
import math
argc = int(input().split()[0])
argv = input().split()
for i in range(argc):
	argv[i] = int(argv[i])
max = max(argv)
min = min(argv)
print(max - min)
if min != max:
	print(argv.count(max) * argv.count(min))
else:
	n = argv.count(max)
	print(n * (n - 1) // 2)


n = int(input())
l = list(map(int, input().split()))
id1 = 0
id2 = 0
mi = l[0]
ma = l[0]
for i in l:
	if i > ma:
		ma = i
	if i < mi:
		mi = i
for i in l:
	if i == mi:
		id1 += 1
	if i == ma:
		id2 += 1
if mi != ma:
	print('{0} {1}'.format(ma - mi, id1 * id2))
else:
	print('{0} {1}'.format(ma - mi, id1 * (id2 - 1) // 2))


n = int(input())
data = [int(i) for i in input().split()]
data.sort()
possible = 0
if data[n - 1] != data[0]:
	possible = data.count(data[0]) * data.count(data[n - 1])
else:
	possible = int((n * n - n) / 2)
print(data[n - 1] - data[0], possible)


def numb(x, n):
	if x == 1:
		return n
	n += x - 1
	numb(x - 1, n)
n = int(input())
bi = sorted(list(map(int, input().split())))
min_num = 0
max_num = 0
for num in bi:
	if num == bi[0]:
		min_num += 1
	if num == bi[-1]:
		max_num += 1
if bi[0] != bi[-1]:
	print(bi[-1] - bi[0], min_num * max_num)
else:
	x = 1
	n2 = 0
	while x < n:
		n2 += x
		x += 1
	print(0, n2)


n = int(input())
b = [int(i) for i in input().split()]
minimum = -1
min_num = 0
maximum = -1
max_num = 0
for i in range(n):
	if b[i] > maximum:
		maximum = b[i]
		max_num = 1
	elif b[i] == maximum:
		max_num += 1
	if b[i] < minimum or minimum == -1:
		minimum = b[i]
		min_num = 1
	elif b[i] == minimum:
		min_num += 1
if max_num < n:
	total = max_num * min_num
else:
	total = n * (n - 1) // 2
print(maximum - minimum, total)


n = int(input())
l = list(map(int, input().split(' ')))
l.sort()
mini = l[0]
maxi = l[n - 1]
minin = l.count(mini)
maxin = l.count(maxi)
c = minin * maxin
if mini == maxi:
	minin -= 1
	c = minin * (minin + 1) // 2
print(maxi - mini, c)


from itertools import combinations
n = int(input())
beauty = list(map(int, input().split()))
most_beauty = max(beauty)
least_beaty = min(beauty)
amount_most = beauty.count(most_beauty)
amount_least = beauty.count(least_beaty)
if most_beauty == least_beaty:
	amount_most = n // 2
	amount_least = n - amount_most
	print(most_beauty - least_beaty, n * (n - 1) // 2)
else:
	print(most_beauty - least_beaty, amount_least * amount_most)


n = input()
l = list(map(int, input().split()))
b = max(l) - min(l)
(f1, f2) = (l.count(max(l)), l.count(min(l)))
if max(l) == min(l):
	print(b, f1 * (f1 - 1) // 2)
	exit(0)
if f1 > 1:
	if f2 > 1:
		print(b, f1 * f2)
	else:
		print(b, f1)
else:
	print(b, 1)


n = int(input())
b = list(map(int, input().split()))
b.sort()
MAX = b[-1] - b[0]
if MAX == 0:
	print(str(0) + ' ' + str(int(n * (n - 1) / 2)))
	exit()
nmin = 1
for i in range(1, n):
	if b[i] != b[0]:
		break
	nmin = nmin + 1
nmax = 1
for i in range(n - 2, -1, -1):
	if b[i] != b[-1]:
		break
	nmax = nmax + 1
print(str(MAX) + ' ' + str(nmax * nmin))


n = int(input())
flowers = sorted(list(map(int, input().split())))
lo = flowers[0]
hi = flowers[-1]
if lo == hi:
	ans = n * (n - 1) // 2
else:
	i = 1
	min_count = 1
	while i < n and flowers[i] == lo:
		i += 1
		min_count += 1
	i = n - 2
	max_count = 1
	while i >= 0 and flowers[i] == hi:
		i -= 1
		max_count += 1
	ans = min_count * max_count
print('%s %s' % (hi - lo, ans))


n = int(input())
l = [int(i) for i in input().split()]
a = max(l)
b = min(l)
c = l.count(a)
d = l.count(b)
print(a - b, end=' ')
if a != b:
	print(c * d)
else:
	print(c * (c - 1) // 2)


from typing import List, Tuple

def parse_input() -> Tuple[int, List[int]]:
	return (int(input()), [int(x) for x in input().split()])

def solve(n: int, b: List[int]) -> Tuple[int, int]:
	max_elem = max(b)
	min_elem = min(b)
	if max_elem == min_elem:
		return (0, n * (n - 1) // 2)
	return (max_elem - min_elem, b.count(max_elem) * b.count(min_elem))
(n, b) = parse_input()
print(' '.join((str(x) for x in solve(n, b))))


n = int(input())
b = [int(i) for i in input().split()]
if len(set(b)) <= 1:
	print(0, int(n / 2 * (n - 1)))
else:
	(x, y) = (max(b), min(b))
	print(x - y, b.count(x) * b.count(y))


n = int(input())
flowers = sorted(list(map(int, input().split())))

def factorial(n):
	x = [1]
	for i in range(1, n + 1):
		x.append(x[i - 1] * i)
	return x[n]
beauty_diff = flowers[-1] - flowers[0]
if beauty_diff == 0:
	num_of_ways = n * (n - 1) // 2
else:
	start = flowers.count(flowers[0])
	end = flowers.count(flowers[-1])
	num_of_ways = start * end
print(beauty_diff, num_of_ways)


a = int(input())
lista = list(map(int, input().split()))
if min(lista) == max(lista):
	print(0, int(a * (a - 1) / 2))
else:
	listaMaior = lista.count(max(lista))
	listaMenor = lista.count(min(lista))
	print(max(lista) - min(lista), listaMaior * listaMenor)


from collections import Counter
N = int(input())
A = list(map(int, input().split()))
A.sort()
C = Counter(A)
if A[0] != A[-1]:
	print(A[-1] - A[0], C.get(A[0]) * C.get(A[-1]))
else:
	X = C.get(A[0])
	print(0, X * (X - 1) // 2)


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
n = int(input())
arr = get_array()
ma = float('-inf')
mi = float('+inf')
for i in arr:
	if i > ma:
		ma = i
	if i < mi:
		mi = i
dic = {}
for i in arr:
	if i not in dic:
		dic[i] = 1
	else:
		dic[i] += 1
if ma == mi:
	N = dic[ma]
	print(0, N * (N - 1) // 2)
else:
	print(ma - mi, dic[ma] * dic[mi])


n = int(input())
lst = list(map(int, input().split()))
maxi = max(lst)
mini = min(lst)
if maxi == mini:
	print(maxi - mini, n * (n - 1) // 2)
else:
	print(maxi - mini, lst.count(maxi) * lst.count(mini))


n = int(input())
a = sorted(list(map(int, input().split())))
diff = a[-1] - a[0]
if diff == 0:
	print(diff, n * (n - 1) // 2)
else:
	print(diff, a.count(a[0]) * a.count(a[-1]))


n = int(input())
ls = list(map(int, input().split()))
m = max(ls) - min(ls)
if m != 0:
	print(m, ls.count(min(ls)) * ls.count(max(ls)))
else:
	print(m, ls.count(min(ls)) * (ls.count(min(ls)) - 1) // 2)


import math
a = int(input())
n = [int(i) for i in input().split()]
m = max(n)
k = min(n)
if m != k:
	print(m - k, n.count(m) * n.count(k))
else:
	print(0, a * (a - 1) // 2)


n = int(input())
b = list(map(int, input().split()))
if b.count(b[0]) == n:
	print(0, n * (n - 1) // 2)
	exit()
b.sort(key=None, reverse=False)
mn = 0
mx = 0
for i in range(n):
	if b[i] == b[0]:
		mn += 1
	elif b[i] == b[n - 1]:
		mx += 1
print(b[n - 1] - b[0], mn * mx)


from functools import reduce
import operator as op
n = int(input())
arr = [int(x) for x in input().split()]

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom
mx = max(arr)
mn = min(arr)
cmx = arr.count(mx)
cmn = arr.count(mn)
if mx != mn:
	print(mx - mn, cmx * cmn)
else:
	print(mx - mn, int(ncr(cmx, 2)))


n = int(input())
s = [*map(int, input().split())]
p = list(set(s))
p.sort()
l = max(s) - min(s)
if n == 2:
	print(l, 1)
elif n > 2 and len(p) == 1:
	print(l, (n - 1) * n // 2)
else:
	q = 0
	q = min(s.count(max(s)), s.count(min(s))) * max(s.count(max(s)), s.count(min(s)))
	print(l, q)


input()
beauty = list(map(int, input().split()))
min_beauty = min(beauty)
max_beauty = max(beauty)
min_count = beauty.count(min_beauty)
max_count = beauty.count(max_beauty)
if max_beauty != min_beauty:
	print(max_beauty - min_beauty, end=' ')
	print(min_count * max_count)
else:
	print(max_beauty - min_beauty, end=' ')
	print(min_count * (max_count - 1) // 2)


x = int(input())
y = list(map(int, input().split()))
if not max(y) - min(y) == 0:
	print(max(y) - min(y), y.count(max(y)) * y.count(min(y)))
else:
	print(0, int(len(y) / 2 * (len(y) - 1)))


import math
n = int(input())
x = sorted(list(map(int, input().split())))
print(x[-1] - x[0], end=' ')
if len(set(x)) == 1:
	print(int(n * (n - 1) / 2))
else:
	print(x.count(min(x)) * x.count(max(x)))


ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
si = lambda : input()
from collections import Counter
n = ii()
cc = Counter(mi())
(mi, ma) = (min(cc), max(cc))
(mic, mac) = (cc[mi], cc[ma])
print(ma - mi, mic * mac if mi < ma else mic * (mac - 1) // 2)


n = int(input())
ls = list(map(int, input().split()))
ls.sort()
mxd = ls[n - 1] - ls[0]
d = {}
d[ls[0]] = 0
d[ls[n - 1]] = 0
if mxd == 0:
	mxw = int(n * (n - 1) / 2)
else:
	for i in ls:
		if i in d:
			d[i] = d[i] + 1
	a = d[ls[0]]
	b = d[ls[n - 1]]
	mxw = a * b
print(mxd, mxw)


n = int(input())
a = list(map(int, input().split()))
a1 = max(a) - min(a)
c1 = a.count(max(a))
c2 = a.count(min(a))
if a1 == 0:
	a2 = n * (n - 1) // 2
else:
	a2 = c1 * c2
print(a1, a2)


num_flowers = int(input())
flowers = sorted(list(map(int, input().split())))
lowest_p = []
highest_p = []
mount = 0
for flower in flowers:
	if flower == flowers[0]:
		lowest_p.append(flower)
for flower in flowers:
	if flower == flowers[-1]:
		highest_p.append(flower)
if lowest_p != highest_p:
	print(flowers[-1] - flowers[0], len(highest_p) * len(lowest_p))
else:
	for (index, flower) in enumerate(flowers):
		mount += index
	print(0, mount)


n = int(input())
l = [int(i) for i in input().split()]
a = max(l)
b = min(l)
if a == b:
	print(0, int(n * (n - 1) / 2))
else:
	print(a - b, l.count(a) * l.count(b))


n = int(input())
L = [int(e) for e in input().split()]
print([str(max(L) - min(L)) + ' ' + str(L.count(max(L)) * L.count(min(L))), '0 ' + str(n * (n - 1) // 2)][max(L) == min(L)])


n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
mincount = 0
maxcount = 0
x = min(arr)
y = max(arr)
if x == y:
	count = 0
	for i in range(len(arr)):
		if arr[i] == x or arr[i] == y:
			count += 1
	ways = count * (count - 1) // 2
	print(0, ways)
else:
	mincount = 0
	maxcount = 0
	for i in arr:
		if i == x:
			mincount += 1
		elif i == y:
			maxcount += 1
	ways = mincount * maxcount
	diff = y - x
	print(diff, ways)


n = int(input())
entradas = list(map(int, input().split()))
entradas.sort()
numMax = 0
minTotal = 0
maxTotal = 0
maxDiff = 0
if entradas[0] == entradas[-1]:
	if n % 2 == 0:
		numMax = int(n / 2) * (n - 1)
	else:
		numMax = int(n / 2) * n
else:
	for i in range(n):
		if entradas[i] == entradas[0]:
			minTotal += 1
		if entradas[i] == entradas[-1]:
			maxTotal += 1
	numMax = minTotal * maxTotal
print(int(entradas[-1] - entradas[0]), int(numMax))


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
a1 = a[-1] - a[0]
c1 = a.count(a[0])
c2 = a.count(a[-1])
if a1 == 0:
	print(0, n * (n - 1) // 2)
else:
	print(a1, c1 * c2)


n = int(input())
flowers = list(map(int, input().split()))
lo = min(flowers)
hi = max(flowers)
if lo == hi:
	ans = n * (n - 1) // 2
else:
	min_count = 0
	max_count = 0
	for i in range(n):
		if flowers[i] == lo:
			min_count += 1
		elif flowers[i] == hi:
			max_count += 1
	ans = min_count * max_count
print('%s %s' % (hi - lo, ans))


n = int(input())
b = list(map(int, input().split()))
cnt1 = 0
cnt2 = 0
mx = max(b)
mn = min(b)
diff = mx - mn
for _b in b:
	if _b == mx:
		cnt1 += 1
	if _b == mn:
		cnt2 += 1
if mn == mx:
	print(str(diff) + ' ' + str(int(n * (n - 1) / 2)))
else:
	print(str(diff) + ' ' + str(cnt1 * cnt2))


n = int(input())
A = input()
B = []
C = []
for i in A.split():
	B.append(int(i))
	C.append(int(i))
B.sort()
C.sort(reverse=True)
count1 = 0
count2 = 0
for j in range(0, n):
	if B[j] != B[0]:
		break
	count1 = count1 + 1
for k in range(0, n):
	if C[k] != C[0]:
		break
	count2 = count2 + 1
if B[0] == C[0]:
	x = 0
	for l in range(1, n):
		x = l + x
	print(0, x)
else:
	print(C[0] - B[0], count1 * count2)


class Code:

	def __init__(self):
		self.n = int(input())
		self.arr = list(map(int, input().split()))

	def process(self):
		print(*[0, self.n * (self.n - 1) // 2]) if max(self.arr) == min(self.arr) else print(*[max(self.arr) - min(self.arr), self.arr.count(max(self.arr)) * self.arr.count(min(self.arr))])
code = Code()
code.process()


from sys import *
from math import *

def main():
	n = int(input())
	b = list(map(int, input().split()))
	ma = max(b)
	mi = min(b)
	x = b.count(ma)
	y = b.count(mi)
	print(ma - mi, end=' ')
	if n == 2:
		print(1, end=' ')
	else:
		print(x * (x - 1) // 2 if ma == mi else x * y)
main()


no_flowers = int(input())
beauty_value = sorted(map(int, input().split()))
beauty_min = beauty_value[0]
beauty_max = beauty_value[-1]
if beauty_min != beauty_max:
	ways = beauty_value.count(beauty_max) * beauty_value.count(beauty_min)
else:
	ways = no_flowers * (no_flowers - 1) // 2
print(str(beauty_max - beauty_min) + ' ' + str(ways))


n = int(input())
arr = sorted([int(p) for p in input().split()])
c1 = arr.count(arr[0])
c2 = arr.count(arr[-1])
if arr[0] == arr[-1]:
	print(0, n * (n - 1) // 2)
else:
	print(arr[-1] - arr[0], c1 * c2)


def codeforces():
	n = int(input())
	b = list(map(int, input().split()))
	mx = max(b)
	mn = min(b)
	max_count = b.count(mx)
	min_count = b.count(mn)
	if mx == mn:
		count = max_count * (max_count - 1) // 2
	else:
		count = max_count * min_count
	mx = mx - mn
	return ' '.join([str(mx), str(count)])
print(codeforces())


n = int(input())
flowers = [int(i) for i in input().split(' ')]
mxm = max(flowers)
mnm = min(flowers)
ans_1 = mxm - mnm
if ans_1 == 0:
	print(0, int((n - 1) * n / 2))
else:
	ans_2 = flowers.count(mxm) * flowers.count(mnm)
	print(ans_1, ans_2)


n = int(input())
b = list(map(int, input().rstrip().split()))
minm = min(b)
maxm = max(b)
x = b.count(minm)
y = b.count(maxm)
if maxm - minm > 0:
	print(maxm - minm, x * y)
else:
	print(0, n * (n - 1) // 2)


from math import factorial

def pashmak_flowers(n, array):
	diff = 0
	max_ = max(array)
	min_ = min(array)
	diff = max_ - min_
	max_n = array.count(max_)
	min_n = array.count(min_)
	if max_n == min_n and max_ == min_:
		print(diff, sum([x for x in range(1, n)]))
	else:
		print(diff, max_n * min_n)
n = input()
array = [int(x) for x in input().split()]
pashmak_flowers(int(n), array)


n = int(input())
v = []
v = input().split()
v2 = []
for e in v:
	v2.append(int(e))
v2.sort()
big = max(v2)
small = min(v2)
res1 = big - small
a = v2.count(big)
b = v2.count(small)
de = n * (n - 1) // 2
if big == small:
	print(0, de)
else:
	res2 = a * b
	print(res1, res2)


from bisect import bisect_left as bs
from math import log as lg
from math import factorial as f
log = lambda *x: print(*x)

def cin(*fn, def_fn=str):
	(i, r) = (0, [])
	if fn:
		def_fn = fn[0]
	for c in input().split(' '):
		r += [(fn[i] if len(fn) > i else def_fn)(c)]
		i += 1
	return r
(n,) = cin(int)
b = sorted(cin(int))
log(b[-1] - b[0], b.count(b[0]) * b.count(b[-1]) if b[0] != b[-1] else int(b.count(b[0]) * (b.count(b[0]) - 1) / 2))


n = int(input())
t = list(map(int, input().split()))
maximum = max(t)
minimum = min(t)
if maximum != minimum:
	types = t.count(maximum) * t.count(minimum)
else:
	types = n * (n - 1) // 2
print(maximum - minimum, types)


n = int(input())
l = list(map(int, input().split()))
mx = max(l)
mn = min(l)
r1 = l.count(mx)
r2 = l.count(mn)
print(mx - mn, end=' ')
if mn == mx:
	print(n * (n - 1) // 2)
else:
	print(r1 * r2)


n = int(input())
a = list(map(int, input().split()))
a.sort()
maxd = a[-1] - a[0]
if maxd == 0:
	countj = n * (n - 1) // 2
else:
	countj = 0
s = sorted(set(a))
l = len(s)
for i in range(l // 2):
	if s[l - 1 - i] - s[i] == maxd:
		countj += a.count(s[l - 1 - i]) * a.count(s[i])
print(maxd, countj)


INF = int(1000000000.0 + 5)
n = int(input())
(x, y, c1, c2) = (INF, -INF, 0, 0)
a = list(map(int, input().split()))
for i in a:
	if i > y:
		y = i
		c2 = 1
	elif i == y:
		c2 += 1
	if i < x:
		x = i
		c1 = 1
	elif i == x:
		c1 += 1
print(y - x, end=' ')
if x != y:
	print(c1 * c2)
else:
	print(c1 * (c1 - 1) // 2)


import math, os, sys
import string, re
import itertools, functools, operator
from collections import Counter

def inputint():
	return int(input())

def inputarray(func=int):
	return map(func, input().split())
n = inputint()
A = list(inputarray())
minv = min(A)
maxv = max(A)
x = Counter(A)
if maxv != minv:
	print('%d %d' % (maxv - minv, x[maxv] * x[minv]))
else:
	print('%d %d' % (0, n * (n - 1) // 2))


n = int(input())
arr = list(map(int, input().split()))
mxm = max(arr)
minm = min(arr)
(min_cnt, max_cnt) = (0, 0)
same = 0
for x in arr:
	if x == arr[0]:
		same += 1
	if x == mxm:
		max_cnt += 1
	if x == minm:
		min_cnt += 1
if same == len(arr):
	print(mxm - minm, n * (n - 1) // 2)
else:
	print(mxm - minm, min_cnt * max_cnt)


n = int(input())
b = list(map(int, input().split()))
diff = max(b) - min(b)
max_app = b.count(max(b))
min_app = b.count(min(b))
if diff is 0:
	sum = 0
	for a in range(n):
		sum += a
	print(diff, sum)
else:
	print(diff, max_app * min_app)


import datetime
import math

def clock():
	print(datetime.datetime.now())
n = int(input())
a = [int(x) for x in input().split()]
s = 0
if max(a) != min(a):
	print(max(a) - min(a), a.count(min(a)) * a.count(max(a)))
else:
	for i in range(n):
		s += i
	print(max(a) - min(a), s)


n = int(input())
m = list(map(int, input().split()))
t = m.count(min(m))
y = m.count(max(m))
if t == len(m):
	print(0, int(len(m) * (len(m) - 1) / 2))
else:
	print(max(m) - min(m), t * y)


n = int(input())
inp = list(map(int, input().split()))
p = max(inp)
q = min(inp)
print(p - q, end=' ')
from collections import Counter
c = Counter(inp)
a = c[p]
b = c[q]
if p == q:
	print(a * (a - 1) // 2)
else:
	print(a * b)


def flowers(n, a):
	a.sort()
	maxdiff = a[-1] - a[0]
	if sum(a) == n * a[0]:
		return [maxdiff, n * (n - 1) // 2]
	c1 = a.count(a[0])
	c2 = a.count(a[-1])
	return [maxdiff, c1 * c2]
n = int(input())
a = list(map(int, input().split()))
print(*flowers(n, a))


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right
from collections import deque

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007
n = I()
arr = L()
mx = max(arr)
mn = min(arr)
if mx == mn:
	print(0, arr.count(mx) * (arr.count(mx) - 1) // 2)
else:
	print(mx - mn, arr.count(mx) * arr.count(mn))


t = int(input())
l = list(map(int, input().split()))
m = max(l)
n = min(l)
print(m - n, end=' ')
if m == n:
	print(t * (t - 1) // 2)
else:
	g = l.count(max(l))
	h = l.count(min(l))
	print(g * h)


n = int(input())
from math import factorial
a = list(map(int, input().split()))
if n == 1:
	print(0, 1)
else:
	a.sort()
	m = a[0]
	p = a[-1]
	if p != m:
		x = a.count(m) * a.count(p)
		print(a[-1] - a[0], x)
	else:
		print(a[-1] - a[0], (n - 1) * n // 2)


n = int(input())
a = sorted(list(map(int, input().split())))
print(a[-1] - a[0], end=' ')
if a[-1] == a[0]:
	print(n * (n - 1) // 2)
else:
	k1 = 1
	i = 1
	while a[i] == a[i - 1]:
		k1 += 1
		i += 1
	k2 = 1
	i = n - 1
	while a[i] == a[i - 1]:
		k2 += 1
		i -= 1
	print(k1 * k2)


n = int(input())
x = list(map(int, input().split()))
a = max(x)
b = min(x)
c = sum((1 for i in x if i == a))
d = sum((1 for i in x if i == b))
if a == b:
	print(str(0) + ' ' + str(n * (n - 1) // 2))
else:
	print(str(a - b) + ' ' + str(c * d))


n = int(input())
a = input().split(' ')
a = [int(i) for i in a]
a = sorted(a)
mn = a[0]
mx = a[-1]
c = mx - mn
if mx == mn:
	t = a.count(mx)
	r = t * (t - 1) // 2
else:
	r = a.count(mx) * a.count(mn)
print(c, r)


n = int(input())
l = list(map(int, input().split()))
a = max(l)
b = min(l)
i = l.count(a)
j = l.count(b)
print(a - b, end=' ')
if a == b:
	print(i * (i - 1) // 2)
else:
	print(i * j)


n = int(input())
flowers = list(map(int, input().split(' ')))
flowers.sort()
diff = flowers[-1] - flowers[0]
if diff != 0:
	ways = flowers.count(flowers[0]) * flowers.count(flowers[-1])
else:
	ways = n * (n - 1) // 2
print(diff, ways)


n = int(input())
l = list(map(int, input().split()))
maxx = max(l)
minn = min(l)
mxc = l.count(maxx)
mnc = l.count(minn)
if maxx == minn:
	print(maxx - minn, n * (n - 1) // 2)
else:
	print(maxx - minn, mxc * mnc)


n = int(input())
a = list(map(int, input().split()))
a.sort()
d = a[-1] - a[0]
i = a.count(a[0])
j = a.count(a[-1])
print(d, i * j if a[0] != a[-1] else int(0.5 * n * n - 0.5 * n), sep=' ')


n = int(input())
l = list(map(int, input().split()))
k = []
l.sort()
for i in range(n):
	if l[i] > l[0]:
		break
for j in range(n - 1, -1, -1):
	if l[j] < l[-1]:
		break
k = [l[-1] - l[0], i * (n - j - 1)]
if l[-1] == l[0]:
	k[1] = n * (n - 1) // 2
print(*k, sep=' ')


t = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
maxx = abs(arr[0] - arr[-1])
x = arr.count(arr[0])
y = arr.count(arr[-1])
if arr[0] == arr[-1]:
	c = x * (x - 1) // 2
	print(maxx, c)
else:
	c = x * y
	print(maxx, c)


import math
n = int(input())
b = list(map(int, input().split()))
maximum = -math.inf
minimum = math.inf
for i in b:
	maximum = max(maximum, i)
	minimum = min(minimum, i)
max_diff = maximum - minimum
count_mx = 0
count_mi = 0
for i in b:
	if i == maximum:
		count_mx += 1
	elif i == minimum:
		count_mi += 1
if max_diff == 0:
	print(max_diff, n * (n - 1) // 2)
else:
	print(max_diff, count_mi * count_mx)


n = int(input())
a = [int(x) for x in input().split()]
amin = amax = a[0]
for i in range(n):
	amin = min(amin, a[i])
	amax = max(amax, a[i])
cmin = cmax = 0
for i in range(n):
	if a[i] == amin:
		cmin += 1
	if a[i] == amax:
		cmax += 1
if amax == amin:
	print(0, cmin * (cmin - 1) // 2)
else:
	print(amax - amin, cmin * cmax)


n = int(input())
p = input()
p = list(map(int, p.split()))
p.sort()
a = p[-1] - p[0]
if a == 0:
	print(a, (n - 1) * n // 2)
else:
	print(a, p.count(p[-1]) * p.count(p[0]))


n = int(input())
l = [int(x) for x in input().split()]
l.sort()
x = l[-1] - l[0]
one = 0
two = 0
ind = 0
while l[ind] == l[0]:
	one += 1
	ind += 1
	if ind == n:
		break
ind = n - 1
while l[ind] == l[-1]:
	two += 1
	ind -= 1
	if ind < 0:
		break
if x == 0:
	print(0, (n - 1) * n // 2)
else:
	print(x, one * two)


import itertools
n = int(input())
b = input().split()
for i in range(len(b)):
	b[i] = int(b[i])
b = sorted(b)
low = b[0]
high = b[len(b) - 1]
if low == high:
	max_diff = 0
	num_ways = len(b) * (len(b) - 1) / 2
else:
	num_low = b.count(low)
	num_high = b.count(high)
	max_diff = high - low
	num_ways = num_high * num_low
print('%d %d' % (max_diff, num_ways))


n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
k = 0
ma = abs(l[0] - l[n - 1])
k1 = 0
k2 = 0
for i in range(n):
	if l[0] == l[i]:
		k1 = k1 + 1
	if l[n - 1] == l[i]:
		k2 = k2 + 1
if ma == 0:
	print(ma, n * (n - 1) // 2)
else:
	print(ma, k1 * k2)


n = int(input())
B = list(map(int, input().split()))
Min = min(B)
Max = max(B)
s = set(B)
if len(s) == 1:
	print(0, B.count(Max) * (B.count(Max) - 1) // 2)
else:
	print(Max - Min, B.count(Max) * B.count(Min))


n = int(input())
b = list(map(int, input().split()))
b = sorted(b)
a = b.count(b[0])
ls = b.count(b[n - 1])

def fact(n):
	ans = 1
	for i in range(n, 1, -1):
		ans *= i
	return ans
if len(list(dict.fromkeys(b))) > 1:
	print(abs(b[0] - b[n - 1]), a * ls)
else:
	print(abs(b[0] - b[n - 1]), n * (n - 1) // 2)


n = int(input())
b = [int(x) for x in input().split()]
maxx = max((pep for pep in b))
minn = min((pep for pep in b))
ans1 = maxx - minn
if maxx > minn:
	max1 = b.count(maxx)
	min1 = b.count(minn)
	ans2 = max1 * min1
else:
	max1 = b.count(maxx)
	ans2 = max1 * (max1 - 1) // 2
print(ans1, ans2)


input()
lst = [int(i) for i in input().split()]
(min, max) = (min(lst), max(lst))
print(max - min, lst.count(min) * lst.count(max) if min != max else lst.count(max) * (lst.count(max) - 1) // 2)


import math

def main():
	n = int(input())
	b = tuple(map(lambda x: int(x), input().split(' ')))
	if len(b) != n:
		raise ValueError('Wrong parameters count')
	find_indices = lambda needle, haystack: [i for (i, x) in enumerate(haystack) if x == needle]
	max_value = max(b)
	min_value = min(b)
	diff = max_value - min_value
	combinations = len(find_indices(max_value, b)) * len(find_indices(min_value, b)) if diff > 0 else n * (n - 1) // 2
	print(diff, combinations)
main()


def factorial(n):
	if n <= 1:
		return 1
	else:
		result = 1
		for i in range(2, n + 1):
			result *= i
	return result

def nCr(n, r):
	numerator = 1
	denominator = 1
	r = min(n - r, r)
	for i in range(1, r + 1):
		denominator *= i
		numerator *= n + 1 - i
	return numerator / denominator
n = int(input())
flowers = list(map(int, input().split()))
flowers.sort()
a = flowers[-1] - flowers[0]
b = 0
if a == 0:
	b = int(nCr(n, 2))
else:
	b = flowers.count(flowers[-1]) * flowers.count(flowers[0])
print(a, b)


n = int(input())
inp = sorted(map(int, input().split()), reverse=True)
print(inp[0] - inp[-1], end=' ')
if inp[0] != inp[-1]:
	gig = inp.count(inp[0])
	gigi = inp.count(inp[-1])
	print(gig * gigi)
else:
	gig = inp.count(inp[0])
	print(gig * (gig - 1) // 2)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	_ = inp()
	lst = inlt()
	lst.sort()
	max_count = 0
	i = len(lst) - 1
	while i >= 0 and lst[i] == lst[-1]:
		max_count += 1
		i -= 1
	min_count = 0
	i = 0
	while i < len(lst) and lst[i] == lst[0]:
		min_count += 1
		i += 1
	max_diff = lst[-1] - lst[0]
	if lst[0] == lst[-1]:
		print(*[max_diff, count(max_count)])
	else:
		print(*[max_diff, min_count * max_count])

def count(n):
	return n * (n - 1) // 2
BUFSIZE = 8192

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from bisect import bisect_left, bisect, bisect_right

def find_ge(a, x):
	i = bisect_left(a, x)
	return i

def find_le(a, x):
	i = bisect_right(a, x)
	return i
n = int(input())
l = list(map(int, input().split()))
l.sort()
diff = l[-1] - l[0]
ans = n * (n - 1) // 2
if diff != 0:
	ans = (n - find_ge(l, l[-1])) * find_le(l, l[0])
print(diff, ans)


n = int(input())
d = dict()
li = [int(x) for x in input().split()]
for i in li:
	if i in d.keys():
		d[i] += 1
	else:
		d[i] = 1
print(max(d) - min(d), end=' ')
if max(d) - min(d) == 0:
	print(d[max(d)] * (d[max(d)] - 1) // 2)
else:
	print(d[max(d)] * d[min(d)])


n = int(input())
b = sorted(list(map(int, input().split())))
print(b[-1] - b[0], end=' ')
if b[0] == b[-1]:
	L = len(b)
	print(L * (L - 1) // 2)
else:
	m = b.count(b[0])
	M = b.count(b[-1])
	print(m * M)


n = int(input())
b = list(map(int, input().split()))
c = sorted(b)
min = c[0]
max = c[n - 1]
(n_min, n_max) = (0, 0)
for ci in c:
	if ci == max:
		n_max += 1
	if ci == min:
		n_min += 1
k = n_min * n_max
if min == max:
	k = int(n * (n - 1) / 2)
print(max - min, k)


n = int(input())
arr = list(map(int, input().split()))
smallest = min(arr)
largest = max(arr)
difference = largest - smallest
if largest != smallest:
	possbilities = arr.count(smallest) * arr.count(largest)
else:
	possbilities = n - 1
	for i in range(possbilities - 1, 0, -1):
		possbilities += i
print(difference, possbilities)


def combinacao(e, comb):
	if e == comb:
		return 1
	if e < comb:
		return 0
	x = e - comb
	result = 1
	if x > comb:
		while e > x:
			result = result * e
			e = e - 1
		while comb > 1:
			result = result // comb
			comb = comb - 1
	else:
		while e > comb:
			result = result * e
			e = e - 1
		while x > 1:
			result = result // x
			x = x - 1
	return result
qtd = int(input())
flowers = input().split()
minF = int(flowers[0])
maxF = int(flowers[0])
mapa = {}
for i in range(qtd):
	flowers[i] = int(flowers[i])
	flower = flowers[i]
	if flower < minF:
		minF = flower
	if flower > maxF:
		maxF = flower
	if flower in mapa:
		mapa[flower] += 1
	else:
		mapa[flower] = 1
maxDif = maxF - minF
result = 0
for key in mapa:
	if maxDif == 0:
		result += combinacao(mapa[key], 2)
	elif key > maxDif:
		if key - maxDif in mapa:
			result += mapa[key] * mapa[key - maxDif]
			mapa[key] = 0
			mapa[key - maxDif] = 0
	elif key < maxDif:
		if key + maxDif in mapa:
			result += mapa[key] * mapa[key + maxDif]
			mapa[key] = 0
			mapa[key + maxDif] = 0
print(maxDif, result)


n = int(input())
flowers = list(map(int, input().split()))
max_beauty = max(flowers)
min_beauty = min(flowers)
count_max = flowers.count(max_beauty)
count_min = flowers.count(min_beauty)
if len(set(flowers)) == 1:
	print(0, int((n - 1) * (n / 2)))
else:
	print(max_beauty - min_beauty, count_max * count_min)


input()
ls = list(map(int, input().split()))
(ma, mi) = (max(ls), min(ls))
(ma_count, mi_count) = (ls.count(ma), ls.count(mi))
print(ma - mi, ma_count * mi_count if ma != mi else ma_count * (ma_count - 1) // 2)


from math import factorial
n = int(input())
val = list(map(int, input().split()))
val.sort()
max_diff = val[-1] - val[0]
(count1, count2) = (0, 0)

def bin_search_right(arr, k):
	low = 0
	high = n - 1
	while low <= high:
		mid = (low + high) // 2
		if arr[mid] == k:
			if mid == n - 1:
				return mid + 1
			elif arr[mid + 1] == k:
				low = mid + 1
			else:
				return mid + 1
		elif arr[mid] > k:
			high = mid - 1
		else:
			low = mid + 1
	return -1

def bin_search_left(arr, k):
	low = 0
	high = n - 1
	while low <= high:
		mid = (low + high) // 2
		if arr[mid] == k:
			if mid == 0:
				return mid
			elif arr[mid - 1] == k:
				high = mid - 1
			else:
				return mid
		elif arr[mid] > k:
			high = mid - 1
		else:
			low = mid + 1
	return -1
if max_diff != 0:
	count1 = bin_search_right(val, val[0])
	count2 = n - bin_search_left(val, val[-1])
	print(max_diff, count1 * count2)
else:
	if n > 2:
		res = int(n * (n - 1) / 2)
	else:
		res = int(factorial(n) / 2)
	print(max_diff, res)


n = int(input())
arr = list(map(int, input().split(' ')))
min_val = arr[0]
max_val = arr[0]
pos_max = [0]
pos_min = [0]
for i in range(1, len(arr)):
	if min_val >= arr[i]:
		if min_val == arr[i]:
			pos_min.append(i)
		else:
			pos_min = []
			pos_min.append(i)
			min_val = arr[i]
	if max_val <= arr[i]:
		if max_val == arr[i]:
			pos_max.append(i)
		else:
			pos_max = []
			pos_max.append(i)
			max_val = arr[i]
diff = max_val - min_val
if diff > 0:
	print(str(diff) + ' ' + str(len(pos_max) * len(pos_min)))
else:
	ct = int(len(pos_max) * (len(pos_max) - 1) / 2)
	print(str(diff) + ' ' + str(ct))


from collections import deque, Counter, OrderedDict
from heapq import nsmallest, nlargest

def binNumber(n, size):
	return bin(n)[2:].zfill(size)

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def iarr():
	return list(map(int, input().split()))

def ini():
	return int(input())

def isep():
	return map(int, input().split())

def si():
	return str(input())
n = ini()
a = iarr()
c = Counter(a)
a.sort()
print(a[len(a) - 1] - a[0], end=' ')
if a[len(a) - 1] != a[0]:
	print(c[a[len(a) - 1]] * c[a[0]])
else:
	print(n * (n - 1) // 2)


import math
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def main():
	n = int(input())
	arr = array()
	arr.sort()
	max_diff = arr[-1] - arr[0]
	m1 = arr.count(arr[0])
	m2 = arr.count(arr[-1])
	if arr[0] != arr[-1]:
		print(max_diff, m1 * m2)
	else:
		print(max_diff, (m1 - 1) * m1 // 2)
t = 1
for _ in range(t):
	main()


def fact(n):
	if n == 0:
		return 0
	if n == 1:
		return 1
	return n + fact(n - 1)

def getNum(d, x):
	key = list(d.keys())
	if len(key) == 1:
		return (d[key[len(key) - 1]] - 1) * (x // 2)
	return d[key[len(key) - 1]] * d[key[0]]
x = int(input().strip('\n'))
y = input().strip('\n').split(' ')
s = [int(i) for i in y]
m = sorted(s)
length = len(m)
mm = m[length - 1] - m[0]
min = 1
max = 1
result = 0
while min < length and m[min] == m[min - 1]:
	min += 1
if min == length:
	if length < 1000:
		result = fact(length - 1)
	else:
		d = {}
		for i in set(m):
			d[i] = m.count(i)
		result = getNum(d, x)
else:
	while max < length and m[length - max - 1] == m[length - 1]:
		max += 1
	result = min * max
print(mm, result)


from math import factorial
n = int(input())
l = input()
l = [int(i) for i in l.split()]
if max(l) != min(l):
	y = max(l) - min(l)
	r = l.count(max(l)) * l.count(min(l))
	print(y, r)
else:
	y = max(l) - min(l)
	i = (l.count(max(l)) - 1) * l.count(max(l)) // 2
	print(y, i)


import math
n = int(input())
li = list(map(int, input().split()))
(M, m) = (max(li), min(li))
a = M - m
cM = li.count(max(li))
cm = li.count(min(li))
b = cM * cm
if M == m:
	print(a, cM * (cM - 1) // 2)
else:
	print(a, b)


n = int(input())
ipline = input()
splitip = ipline.split()
for i in range(0, n):
	splitip[i] = int(splitip[i])
splitip.sort()
maxi = splitip[0]
maxcount = mincount = 0
mini = splitip[-1]
for i in range(0, n):
	if splitip[i] == maxi:
		maxcount += 1
	if splitip[-(i + 1)] == mini:
		mincount += 1
ans1 = abs(maxi - mini)
if maxcount == n:
	if n % 2 == 0:
		ans2 = int(n / 2) * (n - 1)
	else:
		ans2 = int(n / 2) * n
else:
	ans2 = maxcount * mincount
print(ans1, int(ans2))


n = int(input())
a = sorted(list(map(int, input().split())), key=int)
(mini, maxi) = (a[0], a[-1])
(x, y) = (0, 0)
for i in a:
	if i - mini:
		break
	else:
		x += 1
y = n - a.index(maxi)
d = maxi - mini
if d:
	print(d, x * y)
else:
	print(d, n * (n - 1) >> 1)


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
val = a[n - 1] - a[0]
if a[n - 1] == a[0]:
	k = int(n * (n - 1) / 2)
else:
	k = a.count(a[0]) * a.count(a[n - 1])
print(str(val) + ' ' + str(k))


n = int(input())
flowers = list(map(int, input().split()))
flowers.sort()
dif = flowers[n - 1] - flowers[0]
if flowers[0] == flowers[n - 1]:
	nway = n * (n - 1) // 2
else:
	nmax = 1
	nmin = 1
	i = 0
	while flowers[i + 1] == flowers[i] and i < n - 1:
		nmin += 1
		i += 1
	i = n - 1
	while flowers[i] == flowers[i - 1] and i > 0:
		nmax += 1
		i -= 1
	nway = nmax * nmin
print(dif, nway)


n = int(input())
arr = list(map(int, input().split(' ')))
arr.sort()
minm = arr[n - 1] - arr[0]
if arr[n - 1] == arr[0]:
	print(minm, end=' ')
	print(int(n * (n - 1) / 2))
	exit()
cnt1 = 0
cnt2 = 0
for i in arr:
	if i == arr[0]:
		cnt1 += 1
	elif i == arr[n - 1]:
		cnt2 += 1
print(minm, end=' ')
print(cnt1 * cnt2)


n = int(input())
l = list(map(int, input().split()))
a = max(l)
b = min(l)
diff = a - b
ac = 0
bc = 0
for i in range(n):
	if l[i] == a:
		ac += 1
	elif l[i] == b:
		bc += 1
if a == b:
	print(diff, ac * (ac - 1) // 2)
else:
	print(diff, ac * bc)


from collections import Counter
n = input()
n = int(n)
beauty = list(map(int, input().split()))
beauty.sort()
hello = beauty[-1] - beauty[0]
ans = 0
hi = Counter(beauty)
if hi[beauty[0]] == n:
	ans = n * (n - 1)
	ans = int(ans / 2)
else:
	ans = hi[beauty[0]] * hi[beauty[-1]]
print(hello, ans)


x = int(input())
s = [int(i) for i in input().split()]
s.sort()
a = min(s)
b = max(s)
if a == b:
	print(0, int(x * (x - 1) / 2))
else:
	A = 0
	B = 0
	for i in s:
		if i == a:
			A += 1
		if i == b:
			B += 1
	print(b - a, int(A * B))


n = int(input())
flowers = list(map(int, input().split()))
maxBeauty = max(flowers)
minBeauty = min(flowers)
minCount = flowers.count(minBeauty)
maxCount = flowers.count(maxBeauty)
print(maxBeauty - minBeauty, n * (n - 1) // 2 if minBeauty == maxBeauty else minCount * maxCount)


n = int(input())
arr = list(map(int, input().split()))
l = list(set(arr))
d = {}
diff = max(arr) - min(arr)
for i in arr:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
ans = 0
for i in d:
	if i - diff in d:
		if i == i - diff:
			ans += (d[i] - 1) * d[i] // 2
		else:
			ans += d[i] * d[i - diff]
print(diff, ans)


import operator as op
from functools import reduce

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom
n = int(input())
b = list(map(int, input().split()))
max_value = b[0]
min_value = b[0]
count_max = 0
count_min = 0
for (idx, value) in enumerate(b):
	if value > max_value:
		max_value = value
		count_max = 0
	if value < min_value:
		min_value = value
		count_min = 0
	if value == max_value:
		count_max += 1
	if value == min_value:
		count_min += 1
print(max_value - min_value, end=' ')
if count_max == len(b):
	print(ncr(n, 2))
else:
	print(count_min * count_max)


(n, a) = (input(), sorted(list(map(int, input().split()))))
(x, y) = (a.count(a[0]), a.count(a[-1]))
print(a[-1] - a[0], x * y if a[-1] != a[0] else x * (x - 1) // 2)


n = int(input())
b = list(map(int, input().split()))
b.sort()
best = b[-1] - b[0]
if best == 0:
	print(best, n * (n - 1) // 2)
else:
	print(best, b.count(b[-1]) * b.count(b[0]))


n = int(input())
arr = [int(i) for i in input().split()]
arr.sort()
m = arr[-1] - arr[0]
dic = {}
for i in range(n):
	if arr[i] not in dic:
		dic[arr[i]] = 1
	else:
		dic[arr[i]] += 1
l = 0
r = n - 1
ans = 0
while l < r:
	if arr[r] - arr[l] > m:
		l += 1
	elif arr[r] - arr[l] == m:
		if arr[r] != arr[l]:
			ans += dic[arr[l]] * dic[arr[r]]
			l = l + dic[arr[l]]
			r = r - dic[arr[r]]
		else:
			ans += dic[arr[l]] * (dic[arr[l]] - 1) // 2
			break
	else:
		break
print(m, ans)


n = int(input())
mas = list(map(int, input().split()))
a = min(mas)
b = max(mas)
if a != b:
	x = mas.count(a) * mas.count(b)
	print(b - a, x)
else:
	x = mas.count(a)
	k = x - 1
	rez = 0
	for i in range(x - 1):
		rez += k
		k -= 1
	print(0, rez)


import itertools
n = int(input())
arr = [int(i) for i in input().split()]
if len(set(arr)) == 1:
	print(0, int(n * ((n - 1) / 2)))
else:
	print(max(arr) - min(arr), int(arr.count(max(arr)) * arr.count(min(arr))))


import os
import sys
from io import BytesIO, IOBase
from collections import Counter

def solution(arr, n):
	(mi, mx) = (min(arr), max(arr))
	counts = Counter(arr)
	if mx == mi:
		write(0, sum(range(1, n)))
	else:
		write(mx - mi, counts[mi] * counts[mx])

def main():
	n = r_int()
	arr = r_array()
	solution(arr, n)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


n = int(input())
nums = list(map(int, input().split()))
import collections
c = collections.Counter(nums)
res = []
if max(c) == min(c):
	res.append(0)
	res.append(n * (n - 1) // 2)
else:
	res.append(max(c) - min(c))
	res.append(c[max(c)] * c[min(c)])
print(*res)


def selection(num):
	if num < 2:
		return 0
	else:
		return num * (num - 1) // 2
n = int(input())
arr = list(map(int, input().split()))
maxi = mini = arr[0]
for i in range(1, n):
	if maxi < arr[i]:
		maxi = arr[i]
	if mini > arr[i]:
		mini = arr[i]
print(maxi - mini, end=' ')
maxi_count = mini_count = 0
if maxi != mini:
	for i in range(n):
		if maxi == arr[i]:
			maxi_count += 1
		elif mini == arr[i]:
			mini_count += 1
	total = maxi_count + mini_count
	print(selection(total) - selection(maxi_count) - selection(mini_count))
else:
	maxi_count = mini_count = arr.count(maxi)
	print(selection(maxi_count))


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	d = max(arr) - min(arr)
	m = max(arr)
	s = min(arr)
	if all((i == arr[0] for i in arr)):
		print(d, n * (n - 1) // 2)
	else:
		print(d, arr.count(m) * arr.count(s))
main()


def func(n):
	l = list(map(int, input().split()))
	bd = max(l) - min(l)
	if len(set(l)) == 1:
		print(bd, n * (n - 1) // 2)
	else:
		print(bd, l.count(max(l)) * l.count(min(l)))
n = int(input())
func(n)


t = int(input())
a = list(map(int, input().split()))
l1 = a.count(min(a))
l2 = a.count(max(a))
if max(a) == min(a):
	print(max(a) - min(a), l1 * (l2 - 1) // 2)
else:
	print(max(a) - min(a), l1 * l2)


n = int(input())
l = [int(x) for x in input().split()]
if len(set(l)) == 1:
	print(0, n * (n - 1) // 2)
else:
	minn = min(l)
	maxx = max(l)
	d = maxx - minn
	c1 = l.count(minn)
	c2 = l.count(maxx)
	print(d, c1 * c2)


n = int(input())
b = list(map(int, input().split()))
b.sort()
from bisect import *
a1 = bisect_right(b, b[0])
a2 = bisect_left(b, b[n - 1])
if b[0] != b[n - 1]:
	print(b[n - 1] - b[0], a1 * (n - a2))
else:
	print(0, n * (n - 1) // 2)


def pashmakAndFlowers():
	n = int(input())
	b = sorted([int(x) for x in input().split()])
	maxdiff = b[n - 1] - b[0]
	p = q = 0
	if maxdiff == 0:
		f = n - 1
		for i in range(n - 2, 0, -1):
			f = f + i
		count = f
		print(maxdiff, count)
		return
	else:
		for i in range(n):
			if b[i] == b[0]:
				p = p + 1
			elif b[i] == b[n - 1]:
				q = q + 1
		count = p * q
		print(maxdiff, count)
		return
pashmakAndFlowers()


fl = int(input())
bs = [int(b) for b in input().split()]
max = max(bs)
min = min(bs)
diff = max - min
x = 0
y = 0
ans = 0
if min != max:
	for i in range(0, fl):
		if bs[i] == min:
			x = x + 1
		if bs[fl - 1 - i] == max:
			y = y + 1
	ans = x * y
else:
	tmp = fl * (fl - 1) / 2
	ans = int(tmp)
print(diff, ans)


n = int(input())
b = sorted(list(map(int, input().split())))
x = b[n - 1] - b[0]
y = b.count(b[0])
z = b.count(b[n - 1])
if b[0] == b[n - 1]:
	print(x, y * (y - 1) // 2)
else:
	print(x, y * z)


n = int(input())
a = sorted(list(map(int, input().split())))
i = 0
j = 1
if a[0] == a[-1]:
	print(0, n * (n - 1) // 2)
else:
	while a[i] == a[i + 1]:
		i += 1
	while a[-j] == a[-j - 1]:
		j += 1
	i += 1
	print(a[-1] - a[0], i * j)


n = int(input())
a = sorted(map(int, input().split()))
maxi = max(a)
mini = min(a)
l = len(a)
print(maxi - mini, maxi != mini and a.count(maxi) * a.count(mini) or (maxi == mini and l * (l - 1) // 2))


t = int(input())
arr = [int(i) for i in input().split()]
ma = max(arr)
mi = min(arr)
x1 = arr.count(ma)
x2 = arr.count(mi)
if ma != mi:
	print(ma - mi, x1 * x2)
else:
	s = (x1 - 1) * x1 // 2
	print(ma - mi, s)


number = int(input())
beauty = list(map(int, input().split()))
small = min(beauty)
big = max(beauty)
maximum_difference = big - small
if big == small:
	ways = number * (number - 1) // 2
else:
	ways = beauty.count(small) * beauty.count(big)
print(maximum_difference, ways)


n = int(input())
list1 = list(map(int, input().split()))
list1.sort()
p = list1[0]
q = list1[n - 1]
a = list1.count(p)
b = list1.count(q)
if p != q:
	print(abs(p - q), a * b)
else:
	print(abs(p - q), n * (n - 1) // 2)


n = int(input())
l = list(map(int, input().split()))
l.sort()
d = {}
for i in l:
	try:
		d[i] += 1
	except:
		d[i] = 1
if l[-1] - l[0] > 0:
	print(l[-1] - l[0], d[l[-1]] * d[l[0]])
else:
	print(l[-1] - l[0], d[l[-1]] * (d[l[-1]] - 1) // 2)


n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
(a, b) = (arr[0], arr[-1])
d = b - a
c = arr.count(a) * arr.count(b)
if a == b:
	c = n * (n - 1) // 2
print(d, c)


n = int(input())
l = [int(i) for i in input().split()]
print(max(l) - min(l), end=' ')
if len(set(l)) == 1:
	print(n * (n - 1) // 2)
else:
	print(l.count(min(l)) * l.count(max(l)))


a = int(input())
b = list(map(int, input().split()))
b.sort()
if len(set(b)) != 1:
	c = b.count(b[0])
	d = b.count(b[-1])
	print(b[-1] - b[0], c * d)
else:
	k = len(b)
	print(b[-1] - b[0], k * (k - 1) // 2)


n = int(input())
nums = list(map(int, input().split()))
(mx, mn) = (max(nums), min(nums))
(mxc, mnc) = (nums.count(mx), nums.count(mn))
print(mx - mn, mxc * mnc if mx != mn else int((mxc - 1) * mxc / 2))


input()
l = list(map(int, list(input().rstrip().split())))
l.sort()
if l[-1] == l[0]:
	print(0, len(l) * (len(l) - 1) // 2)
	exit(0)
n = k = 0
for e in l:
	if l[0] == e:
		n += 1
	else:
		break
for e in reversed(l):
	if l[-1] == e:
		k += 1
	else:
		break
print(l[-1] - l[0], n * k)


n = int(input())
arr = [int(num) for num in input().split()]
ma = max(arr)
mi = min(arr)
print(ma - mi, end=' ')
if ma != mi:
	print(arr.count(ma) * arr.count(mi))
else:
	print(n * (n - 1) // 2)


n = int(input())
a = list(map(int, input().split()))
a.sort()
i = 0
ln = nn = 1
j = n - 1
while a[i] == a[i + 1] and i < n - 1 and (a[0] != a[-1]):
	i += 1
	nn += 1
while a[j] == a[j - 1] and j > 0 and (a[0] != a[-1]):
	j -= 1
	ln += 1
dis = a[-1] - a[0]
if a[0] != a[-1]:
	k = ln * nn
else:
	k = n * (n - 1) // 2
print(dis, end=' ')
print(k)


import math
n = int(input())
a = list(map(int, input().split()))
a.sort()
(mini, maxi) = (a[0], a[-1])
minicount = maxicount = 0
for i in range(n):
	if a[i] == mini:
		minicount += 1
	else:
		break
for i in range(n - 1, -1, -1):
	if a[i] == maxi:
		maxicount += 1
	else:
		break
if maxi == mini:
	print(maxi - mini, maxicount * (maxicount - 1) // 2)
else:
	print(maxi - mini, minicount * maxicount)


from sys import stdin
inp = lambda : stdin.readline().strip()

def nCr(n, r):
	if r > n - r:
		r = n - r
	ans = 1
	for i in range(1, r + 1):
		ans *= n - r + i
		ans //= i
	return ans
n = int(inp())
a = [int(x) for x in inp().split()]
minimum = min(a)
maximum = max(a)
minCount = 0
maxCount = 0
for i in a:
	if i == minimum:
		minCount += 1
	if i == maximum:
		maxCount += 1
if minimum != maximum:
	print(maximum - minimum, minCount * maxCount)
else:
	print(maximum - minimum, int(nCr(minCount, 2)))


n = int(input())
lt = []
l = sorted(list(map(int, input().split())))
d = l[n - 1] - l[0]
r = l.count(l[0]) * l.count(l[n - 1])
if d == 0:
	n = n - 1
	r = n * (n + 1) // 2
print(d, r)


import collections, math, itertools, bisect, heapq, copy

class Solution:

	def solve(self):
		n = int(input())
		arr = list(map(int, input().rstrip().split()))
		(minVal, maxVal) = (min(arr), max(arr))
		counter = collections.Counter(arr)
		print(maxVal - minVal, end=' ')
		if minVal == maxVal:
			print(n * (n - 1) // 2)
		else:
			print(counter[maxVal] * counter[minVal])
solution = Solution()
solution.solve()


n = int(input())
A = list(map(int, input().split()))
A.sort()
f = 0
b = 1
if A[0] == A[n - 1]:
	print(0, n * (n - 1) // 2)
else:
	while A[f] == A[0]:
		f += 1
	while A[n - 1 - b] == A[n - 1]:
		b += 1
	print(A[n - 1] - A[0], f * b)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = ii()
l = il()
if max(l) == min(l):
	print(0, (n - 1) * n // 2)
else:
	print(max(l) - min(l), l.count(max(l)) * l.count(min(l)))


n = int(input())
d = {}
(l, h) = (None, None)
for i in list(map(int, input().split())):
	if i not in d:
		d[i] = 0
	d[i] += 1
	if l == None:
		(l, h) = (i, i)
	else:
		l = min(i, l)
		h = max(i, h)
print(h - l, end=' ')
if l != h:
	print(d[l] * d[h])
else:
	print(d[l] * (d[l] - 1) // 2)


n = int(input())
flowers = list(map(int, input().split()))
flowers.sort()
minCount = flowers.count(flowers[0])
maxCount = flowers.count(flowers[-1])
print(flowers[-1] - flowers[0], n * (n - 1) // 2 if flowers[0] == flowers[-1] else minCount * maxCount)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
print(arr[-1] - arr[0], end=' ')
val = arr.count(arr[0])
if val == n:
	print(int(n * (n - 1) / 2))
else:
	val1 = arr.count(arr[-1])
	print(arr.count(arr[0]) * arr.count(arr[-1]))


n = int(input())
lis = list(map(int, input().split()))
(i, j) = (0, 0)
mx = max(lis)
mn = min(lis)
if mx == mn:
	print(mx - mn, n * (n - 1) // 2)
else:
	for _ in range(n):
		if mx == lis[_]:
			i += 1
		if mn == lis[_]:
			j += 1
	print(mx - mn, i * j)


n = int(input())
arr = list(map(int, input().split()))
if len(set(arr)) == 1:
	print(f'{0} {int(n * (n - 1) / 2)}')
	exit()
(max_, min_) = (max(arr), min(arr))
(max_count, min_count) = (arr.count(max_), arr.count(min_))
print(f'{max_ - min_} {max_count * min_count}')


__author__ = '-'
n = int(input())
lilled = []
osad = input().split(' ')
for i in range(n):
	lilled.append(int(osad[i]))
vahim = min(lilled)
suurim = max(lilled)
vahimat = 0
suurimat = 0
vastus = 0
if vahim == suurim:
	vastus = n * (n - 1) / 2
else:
	for i in lilled:
		if i == vahim:
			vahimat += 1
		if i == suurim:
			suurimat += 1
	vastus = suurimat * vahimat
print(str(suurim - vahim) + ' ' + str(int(vastus)))


from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
n = iinput()
a = rlinput()
print(max(a) - min(a), a.count(max(a)) * a.count(min(a)) if max(a) != min(a) else n * (n - 1) // 2)


n = int(input())
b = [int(x) for x in input().split()]
b = sorted(b)
num1 = 0
num2 = 0
if b[0] == b[n - 1]:
	print(0, n * (n - 1) // 2)
else:
	for i in b:
		if i == b[0]:
			num1 = num1 + 1
		elif i == b[n - 1]:
			num2 = num2 + 1
	print(b[n - 1] - b[0], num1 * num2)


def meu_map(lista):
	for i in range(len(lista)):
		lista[i] = int(lista[i])

def f(numeros):
	numeros.sort()
	maior = numeros[-1]
	menor = numeros[0]
	diferenca = maior - menor
	if maior == menor:
		return '{} {}'.format(diferenca, n * (n - 1) // 2)
	maiores = 0
	menores = 0
	for i in range(len(numeros)):
		if numeros[i] != menor:
			break
		else:
			menores += 1
	for i in range(len(numeros) - 1, -1, -1):
		if numeros[i] != maior:
			break
		else:
			maiores += 1
	return '{} {}'.format(diferenca, maiores * menores)
n = int(input())
numeros = input().split()
meu_map(numeros)
print(f(numeros))


x = int(input())
arr = [int(i) for i in input().split()]
check = sorted(arr)
minele = check[0]
maxele = check[x - 1]
cont1 = 0
cont2 = 0
if minele != maxele:
	for i in range(x):
		if check[i] == minele:
			cont1 += 1
		if check[i] == maxele:
			cont2 += 1
else:
	for i in range(x):
		if check[i] == minele:
			cont1 += 1
if minele != maxele:
	print(maxele - minele, cont1 * cont2)
else:
	print(minele - maxele, cont1 * (cont1 - 1) // 2)


n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = a[-1] - a[0]
ct = a.count(a[0]) * a.count(a[-1])
if ans == 0:
	ct = a.count(a[0]) * (a.count(a[0]) - 1) // 2
print(ans, ct)


n = int(input())
li = [int(x) for x in input().split(' ')]
li.sort()
b = li.count(li[len(li) - 1])
a = li.count(li[0])
if li[0] == li[len(li) - 1]:
	print(f'0 {int(b * (b - 1) / 2)}')
else:
	print(f'{li[len(li) - 1] - li[0]} {a * b}')


from collections import defaultdict
d = {}
d = defaultdict(int)
n = int(input())
l = list(map(int, input().split()))
l.sort()
m = l[-1] - l[0]
if l[-1] == l[0]:
	print(m, n * (n - 1) // 2)
else:
	print(m, l.count(l[0]) * l.count(l[-1]))


n = int(input())
l = list(map(int, input().split()))
l.sort()
dif = abs(l[n - 1] - l[0])
c1 = c2 = 0
for i in range(n):
	if l[i] == l[0]:
		c1 = c1 + 1
	elif l[i] == l[n - 1]:
		c2 = c2 + 1
if dif == 0:
	print(dif, n * (n - 1) // 2)
else:
	print(dif, c1 * c2)


x = int(input())
a = list(map(int, input().split()))
(n, m) = (max(a), min(a))
if n > m:
	print(n - m, a.count(n) * a.count(m))
if n == m:
	print(0, x * (x - 1) // 2)


def solve(n, nums):
	if len(set(nums)) == 1:
		return [0, n * (n - 1) // 2]
	maxVal = max(nums)
	minVal = min(nums)
	sol1 = maxVal - minVal
	sol2 = nums.count(maxVal) * nums.count(minVal)
	return [sol1, sol2]
n = int(input())
nums = list(map(int, input().split()))
print(' '.join(list(map(str, solve(n, nums)))))


n = int(input())
a = list(map(int, input().split()))
a.sort()
mi = a[0]
ma = a[n - 1]
dif = ma - mi
x1 = int(0)
x2 = int(0)
if dif == 0:
	res = n * (n - 1)
	res //= 2
else:
	for i in a:
		if i == mi:
			x1 += 1
		if i == ma:
			x2 += 1
	res = x1 * x2
print(dif, res)


n = int(input())
b = [int(i) for i in input().split()]
b.sort()
max_diff = b[-1] - b[0]
first_elements = b.count(b[0])
last_elements = b.count(b[-1])
if b[0] != b[-1]:
	print(max_diff, first_elements * last_elements)
else:
	print(0, (len(b) - 1) * len(b) // 2)


(n, inp) = (int(input()), [int(i) for i in input().split(' ')])
(inp_min, inp_max) = (min(inp), max(inp))
c_min = inp.count(inp_min)
if inp_min == inp_max:
	c = n * (n - 1) // 2
else:
	c = inp.count(inp_max) * c_min
print(inp_max - inp_min, c)


n = int(input())
a = list(map(int, input().split()))
a.sort()
x = a[0]
y = a[n - 1]
(count1, count2) = (0, 0)
for i in range(0, n):
	if a[i] == x:
		count1 += 1
	elif a[i] == y:
		count2 += 1
if x == y:
	print(y - x, n * (n - 1) // 2)
else:
	print(y - x, count1 * count2)


n = int(input())
a = list(map(int, input().split()))
a.sort()
d = set(a)
c = a.count(a[n - 1]) * a.count(a[0])
t = a[n - 1] - a[0]
if len(d) == 1:
	c = n * (n - 1) // 2
print(t, c)


import collections
n = int(input())
a = [int(i) for i in input().split()]
diff = max(a) - min(a)
d = collections.Counter(a)
m1 = d[max(a)]
m2 = d[min(a)]
if diff == 0:
	ans = m1 * (m1 - 1) // 2
	print(diff, ans)
else:
	print(diff, m1 * m2)


n = int(input())
s = [int(a) for a in input().split()]
s.sort()
dif = s[-1] - s[0]
if s.count(s[0]) == n:
	way = int((n - 1) * n / 2)
	print(dif, way)
else:
	first = s.count(s[0])
	last = s.count(s[-1])
	way = first * last
	print(dif, way)


n = int(input())
b = [int(x) for x in input().split()]
b.sort()
(h, l) = (b[-1], b[0])
c = n * (n - 1) // 2 if h == l else b.count(h) * b.count(l)
print(h - l, c)


(f, b) = (int(input()), list(map(int, input().split())))
if len(set(b)) > 1:
	print(max(b) - min(b), b.count(max(b)) * b.count(min(b)))
else:
	print(0, f * (f - 1) // 2)


n = int(input())
b = [int(ch) for ch in input().split()]
dict = {}
minNum = pow(10, 10)
maxNum = -1
for num in b:
	if num not in dict:
		dict[num] = 1
	else:
		dict[num] += 1
	minNum = min(minNum, num)
	maxNum = max(maxNum, num)
diff = maxNum - minNum
res = 0
if diff == 0:
	res = int(n * (n - 1) / 2)
else:
	for key in dict:
		if key + diff in dict:
			res += dict[key + diff] * dict[key]
print('{} {}'.format(diff, res))


import sys
length = int(input())
flowers = [int(x) for x in input().split()]
maximum = -1
minimum = sys.maxsize
hashmap = {}
for i in range(len(flowers)):
	if flowers[i] in hashmap:
		hashmap[flowers[i]] += 1
	else:
		hashmap[flowers[i]] = 1
	maximum = max(maximum, flowers[i])
	minimum = min(minimum, flowers[i])
max_diff = maximum - minimum
if max_diff == 0:
	print(max_diff, length * (length - 1) // 2)
else:
	total_ways = 0
	for (key, val) in hashmap.items():
		if key + max_diff in hashmap:
			total_ways += hashmap[key] * hashmap[key + max_diff]
	print(max_diff, total_ways)


(n, s) = (int(input()), list(map(int, input().split())))
if s.count(s[0]) == len(s):
	print(max(s) - min(s), int(n * (n - 1) / 2))
else:
	print(max(s) - min(s), s.count(max(s)) * s.count(min(s)))


n = int(input())
arr = list(map(int, input().split()))
mn = min(arr)
mx = max(arr)
from collections import Counter
c = Counter(arr)
diff = mx - mn
if diff == 0:
	n = c[mx] - 1
	res = (1 + n) * n // 2
	print(diff, res)
else:
	print(diff, c[mx] * c[mn])


n = int(input())
d = [0, 0]
l = sorted(list(map(int, input().rstrip().split())))
for i in range(1, n):
	d += [i + d[-1]]
print(l[-1] - l[0], l.count(l[0]) * l.count(l[-1]) if l.count(l[0]) != len(l) else d[n])


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def solve(n, lst):
	(minn, maxx) = (min(lst), max(lst))
	(minC, maxC) = (lst.count(minn), lst.count(maxx))
	if minn == maxx:
		print(maxx - minn, (minC - 1) * minC // 2)
	else:
		print(maxx - minn, minC * maxC)
n = int(input())
lst = list(map(int, input().split()))
solve(n, lst)


input()
ar = list(map(int, input().split()))
(low, upp) = (min(ar), max(ar))
if low != upp:
	print(upp - low, ar.count(low) * ar.count(upp))
else:
	print(upp - low, ar.count(low) * (ar.count(low) - 1) // 2)


n = int(input())
lst = list(map(int, input().split()))
lst.sort()
mn = lst[0]
mx = lst[len(lst) - 1]
cntmn = cntmx = 0
dif = mx - mn
if mx != mn:
	for i in range(n):
		if lst[i] == mn:
			cntmn += 1
		if lst[i] == mx:
			cntmx += 1
	print(str(dif) + ' ' + str(cntmx * cntmn))
else:
	ans = n
	ans = ans * (ans - 1) // 2
	print(str('0') + ' ' + str(ans))


n = int(input())
flower = list(map(int, input().split()))
max = max(flower)
min = min(flower)
c1 = flower.count(max)
c2 = flower.count(min)
if max == min:
	rslt = n * (n - 1) // 2
else:
	rslt = c1 * c2
print(max - min, rslt)


def array(arr, struc):
	return list(map(struc, arr.split()))
n = int(input())
arr = array(input(), int)
mx = max(arr)
mn = min(arr)
x = arr.count(mx)
y = arr.count(mn)
if mn == mx:
	print(0, x * (x - 1) // 2)
else:
	print(mx - mn, x * y)


n = int(input())
l = list(map(int, input().split()))
if l.count(l[0]) == n:
	print(0, n * (n - 1) // 2)
	exit(0)
m = max(l)
n = min(l)
r = l.count(n) * l.count(m)
print(m - n, r)


import sys
n = int(input())
ls = list(map(int, input().split()))
mn = sys.maxsize
mx = -sys.maxsize
cmn = cmx = 1
for i in range(n):
	if ls[i] == mn:
		cmn += 1
	if ls[i] == mx:
		cmx += 1
	if ls[i] < mn:
		mn = ls[i]
		cmn = 1
	if ls[i] > mx:
		mx = ls[i]
		cmx = 1
print(mx - mn, [cmx * cmn, n * (n - 1) // 2][mx == mn])


n = int(input())
a = [int(i) for i in input().split()]
c = max(a)
d = min(a)
h = 0
b = c - d
if b == 0:
	f = a.count(max(a))
	for i in range(f):
		h += i
else:
	f = a.count(max(a))
	g = a.count(min(a))
	h = f * g
print(b, h)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
n = int(inp())
arr = lmp()
mx = max(arr)
mn = min(arr)
if mx == mn:
	print(0, n * (n - 1) // 2)
else:
	(c1, c2) = (arr.count(mx), arr.count(mn))
	print(mx - mn, c1 * c2)


n = int(input())
a = list(map(int, input().split()))
m = min(a)
m2 = max(a)
if m == m2:
	print(0, n * (n - 1) // 2)
else:
	print(m2 - m, a.count(m) * a.count(m2))


from sys import stdin, stdout
if not __debug__:
	stdin = open('input.txt', 'r')
tcs = int(stdin.readline()) if not __debug__ else 1
t = 1
while t <= tcs:
	n = int(stdin.readline().strip())
	li = list(map(int, stdin.readline().split()))
	li.sort()
	if li[-1] == li[0]:
		print(0, n * (n - 1) // 2)
	else:
		(lc, rc) = (0, 0)
		p = 0
		while p < n and li[p] == li[0]:
			lc += 1
			p += 1
		p = -1
		while p > -n and li[p] == li[-1]:
			rc += 1
			p -= 1
		print(li[-1] - li[0], lc * rc)
	t += 1


n = int(input())
arr = list(map(int, input().split()))
mx = max(arr)
mn = min(arr)
best = mx - mn
flag = False
if arr.count(arr[0]) == n:
	flag = True
cmx = arr.count(mx)
cmn = arr.count(mn)
if flag:
	print(best, n * (n - 1) // 2)
else:
	print(best, cmx * cmn)


q = int(input())
a = list(map(int, input().split()))
m = max(a)
n = min(a)
if m != n:
	print(m - n, a.count(m) * a.count(n), end=' ')
else:
	d = int(q * (q - 1) / 2)
	print(m - n, d, end=' ')


import math
n = int(input())
my_list = list(map(int, input().split(' ')))
my_dict = {}
max = 0
min = 99999999999
for no in my_list:
	if no > max:
		max = no
	if no < min:
		min = no
	if no in my_dict:
		my_dict[no] += 1
	else:
		my_dict[no] = 1
if min != max:
	print(max - min, my_dict[min] * my_dict[max])
else:
	print(max - min, n * (n - 1) // 2)


n = int(input())
array = list(map(int, input().split(' ')))
array.sort()
inf = 0
for i in array:
	if i == array[0]:
		inf += 1
maxi = 0
for i in array:
	if i == array[n - 1]:
		maxi += 1
if inf == n:
	print('0', (n - 1) * n // 2)
else:
	dif = array[n - 1] - array[0]
	ways = inf * maxi
	print(dif, ways)


input()
flowers = [int(x) for x in input().split()]
f_min = min(flowers)
f_max = max(flowers)
if f_min == f_max:
	count = flowers.count(f_min)
	print(0, int(count * (count - 1) / 2))
else:
	min_count = flowers.count(f_min)
	max_count = flowers.count(f_max)
	print(f_max - f_min, min_count * max_count)


from collections import *
n = int(input())
l = [*map(int, input().split())]
dic = Counter(l)
mini = min(l)
maxi = max(l)
if maxi == mini:
	print(0, n * (n - 1) // 2)
else:
	print(maxi - mini, dic[mini] * dic[maxi])


n = int(input())
li = list(map(int, input().split()))
x = max(li)
y = min(li)
cnt1 = li.count(x)
cnt2 = li.count(y)
if x == y:
	c = n * (n - 1) // 2
	print(x - y, c)
	exit()
print(x - y, cnt1 * cnt2)


from sys import stdin
n = int(stdin.readline())
b = [int(i) for i in stdin.readline().split(' ')]
m = -99999999
dic = {}
s = abs(max(b) - min(b))
for i in range(n):
	temp = b[i]
	if temp not in dic:
		dic[temp] = 1
	else:
		dic[temp] += 1
count = 0
temp = set(b)
for i in range(n):
	a1 = b[i]
	if s + a1 in temp:
		count += dic[s + a1]
	elif a1 - s in temp:
		count += dic[a1 - s]
	if s + a1 == a1 or a1 - s == a1:
		count -= 1
print(s, count // 2)


n = int(input())
b = list(map(int, input().split()))
a_min = b[0]
a_max = b[0]
k_min = 1
k_max = 1
for i in range(n - 1):
	if a_min > b[i + 1]:
		a_min = b[i + 1]
		k_min = 1
	elif a_min == b[i + 1]:
		k_min += 1
	if a_max < b[i + 1]:
		a_max = b[i + 1]
		k_max = 1
	elif a_max == b[i + 1]:
		k_max += 1
d = a_max - a_min
if d > 0:
	k = k_max * k_min
else:
	k = int(n * (n - 1) / 2)
print(d, k)


n = int(input())
v = list(map(int, input().split()))
mx = max(v)
mn = min(v)
print(mx - mn, [v.count(mx) * v.count(mn), n * (n - 1) // 2][mx == mn])


import math

def getNum(maxNb, minNb, m):
	s = 0
	if len(set(m)) == 1:
		for i in range(0, minNb):
			s = s + i
		return s
	return minNb * maxNb
x = int(input().strip('\n'))
y = input().strip('\n').split(' ')
s = [int(i) for i in y]
m = sorted(s)
mm = m[len(m) - 1] - m[0]
min = m[0]
max = m[len(m) - 1]
i = 0
minNb = 0
j = len(m) - 1
maxNb = 0
while i < x and min == m[i]:
	minNb = minNb + 1
	i = i + 1
while j >= 0 and max == m[j]:
	maxNb = maxNb + 1
	j = j - 1
print(mm, getNum(maxNb, minNb, m))


import math
a = int(input())
b = [int(x) for x in input().split()]
large_count = 0
small_count = 0
large = max(b)
small = min(b)
for i in range(len(b)):
	if b[i] > large or b[i] == large:
		large = b[i]
		large_count += 1
	elif b[i] < small or b[i] == small:
		small = b[i]
		small_count += 1
diff = large - small
if large == small:
	total = math.floor(a * (a - 1) / 2)
else:
	total = large_count * small_count
print(diff, total)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
n = int(data())
arr = l()
arr.sort()
(a, b) = (arr.count(arr[0]), arr.count(arr[-1]))
if arr[0] == arr[-1]:
	out(0, a * (a - 1) // 2)
	exit()
out(arr[-1] - arr[0], b * a)


a1 = input()
a = int(a1)
(L, k, l) = ([int(x) for x in input().split()], 0, 0)
L.sort()
if L[0] == L[a - 1]:
	t = a * (a - 1) / 2
else:
	for i in range(a):
		if L[i] == L[0]:
			k += 1
	for j in range(a):
		if L[a - 1 - j] == L[a - 1]:
			l += 1
	t = k * l
print(L[-1] - L[0], int(t))


n = int(input())
b = list(map(int, input().split()))
b.sort()
bmx = max(b)
bmi = min(b)
md = bmx - bmi
if md == 0:
	bmi = b.count(bmi)
	c = bmi * (bmi - 1) // 2
else:
	c = b.count(bmi) * b.count(bmx)
print(md, c)


def pashmak(a):
	ma = max(a)
	mi = min(a)
	c1 = a.count(ma)
	c2 = a.count(mi)
	if ma == mi:
		return (ma - mi, c1 * (c1 - 1) // 2)
	return (ma - mi, c1 * c2)
t = int(input())
a = list(map(int, input().split(' ')))
(alpha, beta) = pashmak(a)
print(alpha, beta)


n = int(input())
a = list(map(int, input().split()))
diff = max(a) - min(a)
cnt = a.count(max(a)) * a.count(min(a))
if max(a) == min(a):
	cnt = a.count(max(a)) * (a.count(max(a)) - 1) // 2
print(diff, cnt)


n = int(input())
arr = [int(i) for i in input().split(' ')]
mx = max(arr)
mn = min(arr)
c1 = 0
c2 = 0
for i in range(n):
	if arr[i] == mx:
		c1 += 1
	if arr[i] == mn:
		c2 += 1
if c1 == n:
	print('0' + ' ' + str(int(c1 * (c1 - 1) / 2)))
else:
	print(str(mx - mn) + ' ' + str(int(c1 * c2)))


import math

def comb(x):
	return int(math.factorial(x) / (math.factorial(x - 2) * 2))
n = int(input())
arr = list(map(int, input().split()))
if arr.count(arr[0]) == n:
	print(0, n * (n - 1) // 2)
else:
	max_arr = max(arr)
	min_arr = min(arr)
	print(max_arr - min_arr, arr.count(max_arr) * arr.count(min_arr))


n = int(input())
B = list(map(int, input().split()))
mn = min(B)
mx = max(B)
no_min = 0
no_max = 0
for i in range(n):
	if B[i] == mn:
		no_min += 1
	if B[i] == mx:
		no_max += 1
if mx == mn:
	print(mx - mn, int(n * (n - 1) / 2))
else:
	print(mx - mn, no_min * no_max)


n = int(input())
b = input().split()
for x in range(n):
	b[x] = int(b[x])
b = sorted(b)
x = b.count(max(b))
y = b.count(min(b))
if max(b) != min(b):
	z = x * y
else:
	z = x * (x - 1) // 2
print(max(b) - min(b), z)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
(low, high) = (arr[0], arr[-1])
if low == high:
	print(0, (n - 1) * n // 2)
else:
	i = 0
	while arr[i] == low:
		i += 1
	j = n - 1
	while arr[j] == high:
		j -= 1
	count_low = i
	count_high = n - j - 1
	print(high - low, count_low * count_high)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
flag = 0
if arr[0] == arr[-1]:
	print(0, n * (n - 1) // 2)
	flag = 1
if flag == 0:
	val = arr[0]
	for i in range(n):
		if arr[i] != val:
			break
	maxn = i
	val = arr[-1]
	for i in range(n - 1, -1, -1):
		if arr[i] != val:
			break
	minn = n - i - 1
	print(arr[-1] - arr[0], minn * maxn)


n = int(input())
BeautyNum = list(map(int, input().split(' ')))
BeautyNum.sort()
max = BeautyNum[n - 1] - BeautyNum[0]
big = 0
small = 0
for i in range(n):
	if BeautyNum[i] == BeautyNum[n - 1]:
		big += 1
	elif BeautyNum[i] == BeautyNum[0]:
		small += 1
if max > 0:
	print(max, big * small)
else:
	print(0, n * (n - 1) // 2)


import os
import sys
from math import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def array():
	return [int(i) for i in input().split()]
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
a = sorted(array())
dif = a[-1] - a[0]
if dif == 0:
	print(0, n * (n - 1) // 2)
	exit()
print(a[-1] - a[0], a.count(a[0]) * a.count(a[-1]))


n = int(input())
a = list(map(int, input().split()))
min_n = 10000000000
min_c = 0
max_n = -1
max_c = 0
for i in range(n):
	if a[i] == max_n:
		max_c += 1
	elif a[i] > max_n:
		max_n = a[i]
		max_c = 1
	if a[i] == min_n:
		min_c += 1
	elif a[i] < min_n:
		min_n = a[i]
		min_c = 1
if max_n == min_n:
	print(0, max_c * (max_c - 1) // 2)
else:
	print(max_n - min_n, max_c * min_c)


n = int(input())
l = input()
b = list(map(int, l.split(' ')))
maxb = max(b)
minb = min(b)
cmaxb = b.count(maxb)
cminb = b.count(minb)
if maxb - minb == 0:
	print(maxb - minb, int(n * (n - 1) / 2))
else:
	print(maxb - minb, cmaxb * cminb)


n = int(input())
flowers = input().split()
flower_list = []
for i in flowers:
	i = int(i)
	flower_list.append(i)
flower_list.sort()
max_diff = flower_list[n - 1] - flower_list[0]
flag = True
for i in range(len(flower_list) - 1):
	if flower_list[i] != flower_list[i + 1]:
		flag = False
		break
if flag:
	num_ways = int(n * (n - 1) / 2)
else:
	num_min = 1
	while flower_list[num_min - 1] == flower_list[num_min]:
		num_min += 1
	num_max = 1
	max_counter = n - 1
	while flower_list[max_counter] == flower_list[max_counter - 1]:
		num_max += 1
		max_counter -= 1
	num_ways = num_max * num_min
print(max_diff, num_ways)