n = list(map(int,input().split()))
a = list(map(int,input().split()))
res = 0
for i in range(n[0]):
  for j in range(i,n[0]):
    if i == j:
      SUM = a[i]
    else :
      SUM = a[i] + a[j]
    if SUM % n[1] == 0:
      res += 1
print(res)