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

d = {0: 1}
s = 0
for i in range(N):
  s += A[i]
  m = s % M
  if m in d:
    d[m] += 1
  else:
    d[m] = 1

ans = 0
for v in d.values():
  ans += v * (v - 1) // 2

print(ans)