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