#include <bits/stdc++.h>
int main() {
  int n, d;
  std::cin >> n >> d;
  std::vector<int> arr;
  std::vector<std::vector<int>> answer(n, std::vector<int>(n));
  std::vector<int> used;
  std::copy(std::istream_iterator<int>{std::cin}, std::istream_iterator<int>{},
            std::back_inserter(arr));
  for (size_t i = 0; i < n; i++) {
    for (size_t j = 0; j < n; j++) {
      answer[i][j] = std::max(arr[i], arr[j]) - std::min(arr[j], arr[i]);
    }
  }
  int count = 0;
  for (size_t i = 0; i < n; i++) {
    for (size_t j = i; j < n; j++) {
      if (answer[i][j] > d) {
        used.push_back(j);
      }
    }
  }
  std::sort(used.begin(), used.end());
  auto itr = std::unique(used.begin(), used.end());
  std::vector<int> kek(used.begin(), itr);
  std::cout << std::min(used.size(), kek.size());
}
