from collections import Counter
N,M = map(int,input().split())
A = list(map(int,input().split()))

ctr = Counter()
ctr[0] = 1

cum = 0
for a in A:
    cum = (cum + a) % M
    ctr[cum] += 1

ans = 0
for v in ctr.values():
    ans += v*(v-1)//2
print(ans)