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