#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, count = 0, i, j, d;
  cin >> n >> d;
  long long int a[n + 0];
  for (long long int hh = 0; hh < n + 0; hh++) cin >> a[hh];
  ;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      if (abs(a[i] - a[j]) <= d and i != j) count++;
  cout << count;
}
