from collections import Counter

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

cs = [0] * (N+1)
for i in range(N):
    cs[i+1] = (cs[i] + a[i]) % M

c = Counter(cs)
ans = 0
for k in c.values():
    ans += (k * (k-1))//2
print(ans)
