N,M=map(int,input().split()) A=list(map(int,input().split())) flag=[0 for i in range(M+1)] for i in range(N): flag[A[i]]+=1 if M%2!=0: print(0) exit() ans=0 for i in range(1,M//2+1): j=i+M//2 ans+=flag[i]*flag[j]*(N-flag[i]-flag[j]) print(ans)