#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d, x, cont = 0;
  cin >> n >> d;
  vector<int> v;
  while (n--) {
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) {
    int o = v[i];
    for (int j = i + 1; j < v.size(); j++) {
      int r = v[j] - o;
      if (r <= d) cont += 2;
    }
  }
  cout << cont << endl;
}
