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