#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
int main(){
int n,c,x,a,b;
cin>>n>>c;
for(int i=1;i<=n;i++){
cin>>x;
m[x]++;
}
long long s=0;
for(map<int,int>::iterator it=m.begin();it!=m.end();it++){
b=it->first;
a=b+c;
if(m.count(a)){
s+=m[b]*m[a];
}
}
cout<<s<<endl;
return 0;
}