a,b = map(int,input().split())

c = list(map(int,input().split()))

su = 0
for i in range(len(c)):
	if i == 0:
		c[i] %= 0
	else:
		c[i] += c[i-1]
		c[i] %= b

for i in range(a):
	for j in range(a-i):
		d = sum(c[i:i+j])
		if d < 0:
			d += b+d
		if d % b == 0:
			su += 1

print(su)

