n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

d = {0 : 1}
s = 0
r = 0
for i in range(n):
    s += a[i]
    s %= m
    r += d[s] if s in d else 0
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

print(r)
