#include <bits/stdc++.h>
using namespace std;
int main() {
  int num = 0;
  int n;
  cin >> n;
  int d;
  int sh[n];
  cin >> d;
  for (int i = 0; i < n; i++) cin >> sh[i];
  for (int i = 0; i < n; i++) {
    for (int k = i + 1; k < n; k++) {
      if (abs(sh[i] - sh[k]) <= d) num += 2;
    }
  }
  cout << num;
}
