#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long d;
  cin >> n >> d;
  vector<long long> v;
  long long x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (v[i] - v[j] >= 0 && v[i] - v[j] <= d)
        count++;
      else if (v[j] - v[i] >= 0 && v[j] - v[i] <= d)
        count++;
    }
  }
  cout << count * 2 << endl;
  return 0;
}
