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