N,M = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N):
	A[i] = A[i]%M

b = 0
c = 0
count = 0
for i in range(N):
	b = b+A[i]
	c = b
	if c%M == 0:
		count = count + 1
	for j in range(N-i-1):
		c = c - A[j] + A[j+i+1]
		if c%M == 0:
			count = count + 1
			
print(count)
