#include<bits/stdc++.h>
using namespace std;
int a[100000001];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,c,x;
cin>>n>>c;
for(int i=1;i<=n;i++){
cin>>x;
a[x]++;
}
long long ans=0;
for(int i=c;i<=pow(10,8);i++){
if(a[i]&&a[i-c]) ans+=a[i]*a[i-c];
}
cout<<ans;
return 0;
}