from collections import Counter

N, M = map(int, input().split())
Alist = list(map(int, input().split()))

Blist = list(map(lambda x: x%M, [sum(Alist[:i]) for i in range(len(Alist)+1)]))
Blist.sort()

c = Counter(Blist)

values, counts = zip(*c.most_common())
ans = 0
for count in counts:
    ans += int(count * (count - 1) / 2)

print(ans)