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