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 <bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long ll;
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

	int n, d; cin >> n >> d;
	vector<int> v(n);
	for(int i = 0; i < n; i++)
		cin >> v[i];

	sort(v.begin(), v.end());

	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(i == j) continue;
			if( abs(v[i] - v[j]) <= d)
				ans++;
		}
	}

	cout << ans << "\n";
}
 	 		 	   		    		 	 	 		 		 		