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

count=[0]*M#あまりが0~M-1
S=[0]*(N+1)

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