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