#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long LL;
const int N = 2e5+10;
LL n,C,ans;
int a[N];
unordered_map<LL,LL> has;
int main()
{
cin>>n>>C;
for(int i=0;i<n;i++)
{
cin>>a[i];
has[a[i]]++;
}
for(auto h : has)
{
LL num=h.x, cnt=h.y;
if(has[num+C]) ans+=cnt*has[num+C];
}
cout<<ans;
return 0;
}