import collections
N, M = map(int, input().split())
A = [int(i)%M for i in input().split()]
B = [0]
sum_ = 0
for a in A:
    sum_ = (sum_ + a) % M
    B.append(sum_)
b = collections.Counter(B)
ans = 0
for c in b.values():
    ans += int(c * (c - 1) / 2)
print(ans)