#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  vector<int> x;
  x.push_back(0);
  for (int i = 0; i < n - 1; i++) {
    int r = 0;
    for (int j = i + 1; j < n; j++) {
      if ((v[i] + d) >= v[j])
        r++;
      else
        break;
    }
    x.push_back(r);
  }
  int r = 0;
  for (int i = 0; i < x.size(); i++) r += x[i];
  cout << (2 * r);
}
