#include <iostream>
#include <unordered_map>
using namespace std;
using ll=long long;

int main(){
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int N,C;cin>>N>>C;
    unordered_map<int,int> ump;
    for(int i=0;i<N;++i){
        int num;cin>>num;
        ++ump[num];
    }

    ll cnt=0;
    for(const auto& u:ump){
        auto it=ump.find(C+u.first);
        if(it!=ump.end()) cnt+=(ll)u.second*(it->second);
    }

    cout<<cnt<<'\n';

    return 0;
}