n, m = map(int, input().split(' '))
a = map(int, input().split(' '))

d = {0: 1}
asum = 0
for aa in a:
    asum = (asum + aa) % m
    if asum in d:
        d[asum] += 1
    else:
        d[asum] = 1


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

print(ans)