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