#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  while (cin >> n >> d) {
    int res = 0;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++)
        if (abs(h[i] - h[j]) <= d) res++;
    cout << res * 2 << endl;
  }
  return 0;
}
