#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d, a[1000], t, c = 0, i, j;
  cin >> n >> d;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n, greater<int>());
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      t = a[i] - a[j];
      if (t <= d) {
        c++;
      }
    }
  }
  cout << 2 * c << "\n";
  return 0;
}
