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