N, M = map(int, input().split()) A = list(map(int, input().split())) A.sort() if M & 1 : print(0) exit() ans = 0 fl = 0 for a in A : while fl < N and A[fl] < a + (M // 2) : fl += 1 if A[fl] == a + (M // 2) : ans += 1 print(ans * (N - 2))