Closest points
Time: 1 s · Memory: 256 MB
- Sorting
Statement
You are given distinct points on a number line. Find the smallest distance between two points and the number of pairs of points at that distance. The distance between points and is .
Input format
The first line contains (). The second line contains distinct integers () — the coordinates.
Output format
A single line with two numbers: the smallest distance and the number of pairs at that distance.
Examples
Input
5 9 1 5 11 3
Output
2 3
Input
4 -4 8 2 14
Output
6 3
Note
Checking all pairs is — operations for . Sort the points: the closest point is always a neighbour in the sorted array, so the differences are enough.
The distance can reach , which does not fit into a 32-bit int: 2 3 in the first example, and for the points -2000000000 and 2000000000 the answer is 4000000000 1.
Source: acmp.ru, problem 344.
