#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define maxn 1000003
using namespace std;
const unsigned long long mod=904736;
typedef unsigned long long ULL;
struct data{
ULL tot,x;
}t[maxn];
ULL n,c;
ULL a[maxn],ans;
void deal(ULL x){
ULL i=x%mod;
while(t[i].tot!=0&&t[i].x!=x) i=(i+1)%mod;
t[i].tot++; t[i].x=x;
}
void ask(ULL x){
ULL i=x%mod;
if(t[i].tot!=0){
ans+=t[i].tot;
}
}
int main()
{
cin>>n>>c;
for(int i=1;i<=n;i++){
cin>>a[i];
deal(a[i]);
}
for(int i=1;i<=n;i++){
ask(a[i]+c);
}
cout<<ans;
return 0;
}