# -*- coding: utf-8 -*-

N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
for i in range(len(A)):
	for j in range(len(A) - i):
		if sum(A[i:j+i+1]) % M == 0:
			ans += 1

print(ans)
