#include using namespace std; int main(){ int N, M; cin >> N >> M; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } if (M % 2 == 1){ cout << 0 << endl; return 0; } long long ans = 0; for (int i = 0; i < N; i++){ auto it = lower_bound(A.begin(), A.end(), A[i] + M / 2); if (it != A.end() and *it == A[i] + M / 2){ ans += N - 2; } } cout << ans << endl; }