from itertools import accumulate
N,M = map(int,input().split())
A = list(map(int,input().split()))
As = [0] + list(accumulate(A))
As = [i%M for i in As]
count = [0 for i in range(M)]
ans = 0
for i in As:
    ans += count[i]
    count[i] += 1
print(ans)