#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, ar[10008], c = 0;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> ar[i];
  }
  sort(ar + 1, ar + n + 1);
  for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++) {
      if (ar[j] - ar[i] <= k) c++;
    }
  cout << 2 * c;
  return 0;
}
