N,M=map(int,input().split())
A=[int(i) for i in input().split()]
S=[0 for i in range(N+1)]
for i in range(N):
  S[i+1]=(S[i]+A[i])%M
D=dict()
ans=0
for i in range(N+1):
  if S[i] in D:
    D[S[i]]+=1
  else:
    D[S[i]]=1
  ans+=D[S[i]]-1
print(ans)
