#include <bits/stdc++.h>
const int MX = 1e5 + 100;
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  long long a[1000];
  int c = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (fabs(a[i] - a[j]) <= d) c += 2;
  cout << c;
  getchar();
  getchar();
  return 0;
}
