#include <bits/stdc++.h>
int main() {
  long long int n, d, a[1000], i, j, k = 0;
  scanf("%I64d %I64d", &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 (abs(a[i] - a[j]) <= d) k++;
    }
  }
  printf("%d", k - n);
}
