from collections import Counter
from itertools import accumulate

N, M = map(int, input().split())
Al = [int(x) for x in input().split()]
ans = 0
for val in Counter([0] + [A % M for A in accumulate(Al)]).values():
	ans += val * (val - 1) / 2
print(int(ans))
