#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, d;
  cin >> n >> d;
  vector<int> so(n);
  for (auto &x : so) {
    cin >> x;
  }
  int ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (abs(so[j] - so[i]) <= d) {
        ++ans;
      }
    }
  }
  cout << ans * 2;
  return 0;
}
