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