#include <bits/stdc++.h>
using namespace std;
int arr[100002], result = 0;
int main() {
  int N = 0, maxN = 0;
  cin >> N >> maxN;
  for (int i = 0; i < N; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (j == i) continue;
      if (abs(arr[i] - arr[j]) <= maxN) {
        result++;
      }
    }
  }
  cout << result;
  return 0;
}
