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.

Difficulty: interview

Starter code:

Solutions:
"""
Codeforces Contest 261 Div 2 Problem B

Author  : chaotic_iak
Language: Python 3.3.4
"""

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)

################################### NON-SOLUTION STUFF BELOW

def read(mode=2):
    # 0: String
    # 1: List of strings
    # 2: List of integers
    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())

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()))
bmin = min(b)
bmax = max(b)
if bmin != bmax:
    print(bmax-bmin, b.count(bmin)*b.count(bmax)) 
else:
    print(0, n*(n-1)//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())
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)


3

import sys

n = int(sys.stdin.readline())
b = [int(x) for x in sys.stdin.readline().split()]
b.sort()

if b[0] == b[-1]:
    # Difference is zero
    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())
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)


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)




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 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)
    return
diff = max1-min1
no_ways = d[max1]*d[min1]
print(diff,no_ways)



import fileinput
import math

for line in fileinput.input():   
    inp = [ int(i) for i in line.split()]

N = len(inp)


#case 1, all inputs are the same

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)


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())
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 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())
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)

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
#print(c1,c2)
if a==b :
    summ = 0
    for i in range(n-1,0,-1):
        summ += i
        
    print(diff,summ )
else:
    print(diff, c1*c2)


#!/usr/bin/env python3

INF = int (1e9+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)


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())
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())
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)

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


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)

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))
    return
    
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)))