N,M=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]

cup={}


s=0
cup[s]=1
for num in A:
	s+=num
	s%=M
	if s in cup.keys():
		cup[s]+=1
	else:
		cup[s]=1

res=0
for num in cup.values():
	res+=num*(num-1)//2
print(res)
