from collections import Counter
from itertools import accumulate
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
C = Counter([0] + [a % M for a in accumulate(A)])
cnt = 0
for c in C.values():
  cnt += c * (c - 1) // 2
print(cnt)