#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, *x, d, count = 0;
  cin >> n >> d;
  x = new int[n];
  for (int i = 0; i < n; i++) cin >> x[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i != j)
        if (abs(x[i] - x[j]) <= d) count++;
  cout << count;
}
