N,M=list(map(int,input().split()))
A=list(map(int,input().split()))
C=[]
for i in range(len(A)):
    if i == 0:
        C.append(0)
    else:
        C.append(C[i-1]+A[i])

mod=[]
for i in range(len(C)):
    mod.append(C[i]%M)

k=0
mod.sort()
print(mod)
for i in range(1,len(mod)):
    if mod[i]==0:
        k+=1
n=1
t=0
for i in range(1,len(mod)):
    if i < len(mod)-1:
        if mod[i-1]==mod[i]:
            n+=1
        elif n>=2:
            t+=int(n*(n-1)/2)
            n=1
        else:
            pass
    else:
        if n>=2:
            if mod[i-1]==mod[i]:
                n+=1
            else:
                pass
            t+=int(n*(n-1)/2)
        else:
            if mod[i-1]==mod[i]:
                t+=1
            else:
                pass

print(k+t+1)

