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



countlist=[]
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=[0 for i in range(M)]
check=set()


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





ANS=countlist[0]

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

print(ANS)
