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

ans = 0

temp = 0
b = {0:1}
for x in a:
    temp = (temp + x) % m
    if temp in b:
        b[temp] += 1
    else:
        b[temp] = 1

for x in b.values():
    ans += x * (x - 1) // 2

print(ans)