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