#include <iostream>
#include <set>
using namespace std;
int main() {
int n, c;
cin >> n >> c;
int a;
multiset<int> ms;
while (n--)
{
cin >> a;
ms.insert(a);
}
int y = 0;
set<int> s(ms.begin(), ms.end());
for(auto x : s)
{
if (ms.find(x + c) != ms.end())
y += ms.count(x) * ms.count(x + c);
}
cout << y;
return 0;
}
// 64 位输出请用 printf("%lld")

京公网安备 11010502036488号