def iin(): return int(input())
def nl(): return list(map(int, input().split()))

n, m = nl()
a = nl()

b = [0]
for x in a:
    t = (b[-1] + x) % m
    b.append(t)

ans = 0
d = dict()
for x in b:
    t = d.get(x, 0)
    ans += t
    d[x] = t + 1

print(ans)