#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return f * x;
}
const int maxn = 1e5 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e8 + 7;
int a[maxn];
int b[maxn] = {0};
int main() {
  int n, d;
  cin >> n >> d;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  int count = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (abs(a[j] - a[i]) <= d) {
        count++;
      }
    }
  }
  printf("%d", count * 2);
  return 0;
}
