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

_A.sort()


_count=0
for i in range(len(_A)-1):

    if _A[i]==_A[i+1]:
        _count+=1
    else:
        count+=(_count+1)*_count/2
        _count=0

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