#include <bits/stdc++.h>
int main() {
  int x, y, i, f, sum = 0;
  scanf("%d%d", &x, &y);
  int z[x];
  for (i = 0; i < x; i++) scanf("%d", &z[i]);
  for (i = 0; i < x; i++) {
    for (int j = i + 1; j < x; j++) {
      f = z[i] - z[j];
      if (f < 0) f = (-f);
      if (f <= y) {
        sum += 2;
      }
    }
  }
  printf("%d\n", sum);
  return 0;
}
