#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  int a[n], c = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (d == 0) {
    cout << d;
  } else {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (a[i] - a[j] == d) {
          c++;
        }
      }
    }
    cout << c;
  }
}
