N,M=map(int,input().split())
A=list(map(int,input().split()))
from itertools import accumulate
from collections import Counter
A=[0]+list(map(lambda x:x%M,accumulate(A)))
A=Counter(A).values()
ans=0
for a in A:
    ans+=a*(a-1)//2
print(ans)