#include <bits/stdc++.h>
using namespace std;
int arr[1500];
int main() {
  int n, d;
  cin >> n >> d;
  for (int i = 0; i < n; ++i) scanf("%d", &arr[i]);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j)
      if (abs(arr[i] - arr[j]) <= d) ans += 2;
  }
  cout << ans << endl;
  return 0;
}
