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

d = {0: 1}
asum = 0
for a in map(int, input().split(' ')):
    asum = (asum + a) % m
    if asum in d:
        d[asum] += 1
    else:
        d[asum] = 1


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

print(ans)