from collections import Counter

N, M= [int(x) for x in input().strip().split(' ')]
A = [int(a) for a in input().split()]
A_mod = [A[0] % M]
s = 0
for elem in A:
    A_mod.append((elem+s) % M)
    s += elem

cnt = Counter(A_mod)
c = 0
for k in cnt.keys():
    if cnt[k] != 0.0 and cnt[k] != 1.0:
        c += (cnt[k])*(cnt[k]-1)/2

print(int(c))