n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [0]
for i in a:
    b.append((b[-1] + i) % m)
c = {}
for i in b:
    if i in c:
        c[i] += 1
    else:
        c[i] = 1
d = 0
for i in c:
    d += c[i] * (c[i] - 1) // 2
print(d)