from collections import Counter

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

b = [0]
for i in a:
    b.append((b[-1]+i) % m)
 
r = 0
for v in Counter(b).values():
    r += v * (v-1) // 2
print(r)