N, M = map(int, input().split())
a = list(map(int, input().split()))
s = 0
ss = {0: 1}
for n in a:
    s += n
    ss[s % M] = ss.get(s % M, 0) + 1
ans = 0
for n in ss.values():
    if n > 1:
        ans += n * (n - 1) // 2
print(ans)
