#include <bits/stdc++.h>
using namespace std;
int fact(int n) {
  int f = 1;
  for (int i = 1; i <= n; ++i) f = f * i;
  return f;
}
void solve() {
  int n, k, cnt = 0;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j)
      if (abs(a[j] - a[i]) <= k) cnt++;
  cout << cnt * 2 << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tc = 1;
  while (tc--) {
    solve();
  }
  return 0;
}
