#include <bits/stdc++.h>
using namespace std;
int compare(const void *a, const void *b) { return (*(int *)a - *(int *)b); }
int main() {
  long long n, d, counter = 0;
  cin >> n >> d;
  long long *h = new long long[n];
  for (int i = 0; i < n; i++) cin >> h[i];
  qsort(h, n, sizeof(long long), compare);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (h[j] - h[i] > d) break;
      counter++;
    }
  }
  cout << 2 * counter;
  return 0;
}
