#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, c = 0;
  cin >> n;
  long long int d;
  cin >> d;
  long long int s[n + 5];
  for (long long int i = 0; i < n; i++) {
    cin >> s[i];
  }
  sort(s, s + n);
  for (long long int i = 0; i < n - 1; i++) {
    for (long long int j = i + 1; j < n; j++) {
      if (s[j] - s[i] <= d) {
        c++;
      }
    }
  }
  cout << c * 2 << endl;
  return 0;
}
