#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, ans = 0, d;
  cin >> n >> d;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      if ((i != j) && abs(a[i] - a[j]) <= d) ans++;
    }
  }
  cout << ans;
}
