#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> usingnamespace std; typedeflonglong LL; constint N = 2e5+10; int f[N]; intmain(){ int n, c; cin>>n>>c; for(int i=0;i<n;i++) scanf("%d",&f[i]); LL ans = 0; sort(f,f+n,greater<int>()); for(int i=0;i<n-1;i++){ int x = f[i]-c; if(x<0) break; int l = i, r = n-1; while(l<r){ int mid = l + r >> 1; if(f[mid]<=x) r = mid; else l = mid+1; } if(f[l]==x){ ans++; int ll = l; r = n-1; while(ll<r){ int mid = ll+r+1>>1; if(f[mid]>=x) ll = mid; else r = mid - 1; } ans+=r-l; } } cout<<ans<<endl; return0; }