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