#105_D
N,M=map(int,input().split())
A=list(map(int,input().split()))
S=[0]*(N+1)
for i in range(N):
    S[i+1]=S[i]+A[i]
S_Mod=[S[i]%M for i in range(N+1)]

cnt=0
for x in range(M):
    cnt+=S_Mod.count(x)*(S_Mod.count(x)-1)//2
print(cnt)