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