#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  int prb[n];
  for (int i = 0; i < n; i++) cin >> prb[i];
  int cnt = 0;
  sort(prb, prb + n);
  for (int i = 0; i < n - 1; i++)
    for (int j = i + 1; j < n; j++)
      if ((prb[j] - prb[i]) <= d) cnt += 2;
  cout << cnt << endl;
  return 0;
}
