#include <bits/stdc++.h>
int main(int argc, char** argv) {
  int n, d, vector[1001], i, j, total = 0;
  scanf("%d %d", &n, &d);
  for (i = 0; i < n; i++) scanf("%d", &vector[i]);
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      if ((j != i) && (abs(vector[j] - vector[i]) <= d)) total++;
  printf("%d\n", total);
  return 0;
}
