Codeforces Round 261 (Div. 2)
B
Pashmak and Flowers
Codeforces
1300
原题
← AC →
翻译中…

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:

翻译中…
  1. The maximum beauty difference of flowers that Pashmak can give to Parmida.
  2. 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.

翻译中…

Note

翻译中…

In the third sample the maximum beauty difference is $2$ and there are $4$ ways to do this:

翻译中…
  1. choosing the first and the second flowers;
  2. choosing the first and the fifth flowers;
  3. choosing the fourth and the second flowers;
  4. choosing the fourth and the fifth flowers.
翻译中…

样例

Input #1
2
1 2
Output #1
1 1
InputCopy OutputCopy
Input #2
3
1 4 5
Output #2
4 1
InputCopy OutputCopy
Input #3
5
3 1 2 3 1
Output #3
2 4
InputCopy OutputCopy
题目信息
题号
459B
时间限制
1 s
内存限制
256 MB
标签
组合数学
模拟
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。