#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7, N = 1e5 + 10;
void solve() {
  int n, d, ans = 0, sum = 0;
  cin >> n >> d;
  int a[n], diff[n - 1];
  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[i] - a[j]) <= d) {
        ans++;
      }
    }
  }
  cout << 2 * ans;
  return;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int test = 1;
  while (test--) {
    solve();
  }
}
