#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, n, d, res = 0, a[2000];
  scanf("%d %d", &n, &d);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      if (i == j)
        continue;
      else if (abs(a[i] - a[j]) <= d)
        res++;
  cout << res << endl;
  return 0;
}
