#include <bits/stdc++.h>
using namespace std;
long long n,m,cnt;
long long a[1000000],b[1000000];
int main(){
cin>>n>>m;
for (long long i=1;i<=n;i++){
cin>>a[i];
}
sort(a+1,a+n+1);
for (long long i=1;i<=n;i++){
b[i]=a[i]-m;
cnt+=(upper_bound(a+1,a+n+1,b[i])-a)-(lower_bound(a+1,a+n+1,b[i])-a);
}
cout<<cnt<<endl;
return 0;
}