n,m = map(int,input().split())

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

b = [0 for i in range(n+1)]

for i in range(n):
	b[i+1] = b[i]+a[i]


ans = 0
for i in range(n):
	for j in range(1,n-i+1):
		if (b[i+j] - b[i]) % m == 0:
			ans += 1

print(ans)