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

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