#include <cstdio>
#include <algorithm>
#include <iostream>


int a[434567];

using namespace std;

int main() {
  freopen("che.in", "r", stdin);
  freopen("che.out", "w", stdout);
  int n, r;
  scanf("%d%d", &n, &r);
  for (int i = 0; i < n; i++) 
	scanf("%d", &a[i]);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) { 
      if (a[j] - a[i] > r) ans++;
    }
  } 
  cout << ans;
}