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

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