from collections import Counter

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

Blist = [sum(Alist[:i])%M for i in range(len(Alist)+1)]
c = Counter(Blist)

ans = 0
for key, val in c.items():
    ans += val * (val - 1) / 2

print(int(ans))