Pairs of points
Problem
There are
N
points on the line. It is required to count the number of index pairs (
i
,
j
) such that i < j and |a
i - a
j|
Input
The first line contains two numbers N and D (1 <= N <= 10
5, 1 <= D <= 10
9). The second line contains N non-negative numbers, each of which is no more than 2*10
9.
Imprint
Display the answer to the problem.
Examples
# |
Input |
Output |
1 |
5 3
1 3 4 7 8
| 5 |