import math

N,M=map(int,raw_input().split())
A=map(int,raw_input().split())

def ncr(n,r):
	return math.factorial(n) / math.factorial(r) / math.factorial(n-r)


S={}
sum=0
for  idx,x in enumerate(A):
	sum+=x
	b=sum%M
	if b not in S:
		S[b]=[idx]
	else:
		S[b].append(idx)


ans=0
for i,x in S.items():
	L=len(x)
	if i==0: ans+=L
	if L>=2:
		ans+=ncr(L,2)

print ans
	
