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