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

a = A[0]
sum_A = []
for g in range(1,N+1):
	sum_A.append(a)
	if g<=N-1:
		a +=  A[g]

l=0
r=0
ans=0
while True:
	if r==l:
		if sum_A[l]%M==0:
			ans+=1
			r+=1
		else:
			r+=1
	else:
		if (sum_A[r]-sum_A[l])%M==0:
			ans+=1
			r+=1
		else:
			r+=1

	if r==N:
		l += 1
		r = l
	if l == N:
		break

print(ans)