#include <bits/stdc++.h>
using namespace std;
int main() {
  int b, i, j, k, l, n, m, count = 0;
  int a[100000];
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (abs(a[i] - a[j] <= m) && abs(a[j] - a[i] <= m)) count++;
    }
  }
  printf("%d\n", count * 2);
  return 0;
}
