from math import factorial
def combi(n,r):
  res = factorial(n) / factorial(r) / factorial(n - r)
  return int(res)

N,M = list(map(int,input().split()))
a = list(map(int,input().split()))

data = {}

tmp = 0
for i in range(N):
  tmp += a[i]
  if tmp%M not in data:
    data[tmp%M] = 1
  else:
    data[tmp%M] += 1
else:
  data[0] += 1

cnt = list(data.values())
ans = 0
for i in cnt:
  if i == 1:
    continue
  else:
    ans += combi(i,2)
print(ans)