#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
const int MAX = 1002;
long long a[MAX];
int main(int argc, char** argv) {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a[j] - a[i] <= m)
        ans += 2;
      else
        break;
    }
  }
  cout << ans;
  return 0;
}
