N,M=[int(i) for i in input().split(" ")]
A=[int(i) for i in input().split(" ")]

_A=[sum(A[:i:])%M for i in range(N+1)]

count=0





for i in set(_A):
    _count=_A.count(i)

    count+=(_count-1)*_count/2
print(int(count))
