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

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


def tr(k):
    return k*(k-1)//2


countlist=dict()
check=set()


for i in range(1,N+1):
    countlist[S[i]]=countlist.get(S[i],0)+1
    check=check|{S[i]}
    
    





ANS=int(countlist.get(0,0))



for i in check:
    ANS+=tr(int(countlist[i]))



print(ANS)

