According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most *d* centimeters. Captain Bob has *n* soldiers in his detachment. Their heights are *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> centimeters. Some soldiers are of the same height. Bob wants to know, how many ways exist to form a reconnaissance unit of two soldiers from his detachment.

Ways (1, 2) and (2, 1) should be regarded as different.
The first line contains two integers *n* and *d* (1 ≤ *n* ≤ 1000, 1 ≤ *d* ≤ 10<sup class="upper-index">9</sup>) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains *n* space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 10<sup class="upper-index">9</sup>.
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int read(){ 
    int w = 1, s = 0; 
    char ch = getchar(); 
    while (ch < '0' || ch>'9') { 
        if (ch == '-') w = -1; 
        ch = getchar(); 
    }
    while (ch >= '0' && ch <= '9') { 
        s = s * 10 + ch - '0';    
        ch = getchar(); 
    }
    return s * w; 
}
int a[1010];
signed main()
{
	int n = read();
	int d = read();
	int res = 0;
	memset(a, 0, sizeof(a));
	for (int i = 0; i < n; i++)
		a[i] = read();
	sort(a, a + n);
	for (int i = 0; i < n; i++)
	{
		int cnt = 0;
		for (int j = i + 1; a[j] - a[i] <= d && j < n; j++)
			cnt++;
		res += 2 * cnt;
	}
	printf("%lld\n",res);
	return 0;
}