#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1001;
int n, d, A[MAXN];
int solve() {
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i != j) {
        if (abs(A[j] - A[i]) <= d) ans++;
      }
  return ans;
}
int main() {
  cin >> n >> d;
  for (int i = 0; i < n; i++) cin >> A[i];
  cout << solve() << endl;
  return 0;
}
