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