#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long> v;
  long n, m, i, j, a, b;
  cin >> n >> m;
  long nn = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < v.size(); j++) {
      if (i != j and abs(v[i] - v[j]) <= m) nn++;
    }
  }
  cout << nn << endl;
  return 0;
}
