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

ans = 0

for i in range(N):
  wa = sum(candy[0:i+1])
  for j in range(N-i-1):
    if wa % M == 0:
      ans += 1
    wa = wa - candy[j] + candy[i+j+1]
    
  if wa % M == 0:
    ans += 1
    
print(ans)
  