import collections N,M = map(int, input().split()) A = list(map(int, input().split())) C = collections.Counter() for a in A: C[a%M]+=1 ans = 0 for k,v in C.items(): ans+=v*C[M/2+k]*(N-C[k]-C[M/2+k]) print(ans)