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