#include<bits/stdc++.h>
using namespace std;
int main()
{
long long n,c,he=0,t;
map<int,int> s;
cin>>n>>c;
for(int i=0;i<n;i++)
{
cin>>t;
if(s.count(t))
s[t]++;
else
s[t]=1;
}
for(map<int,int>::iterator i=s.begin(); i!=s.end();i++)
{
if(s.count(i->first-c))
{
long long t2=(i->second)*s[i->first-c];
he+=t2;
}
}
cout<<he;
return 0;
}
92分