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] + [x % M for x in accumulate(A)])
ans = 0
for v in c.values():
    ans += v * (v - 1) // 2
print(ans)