N, M = map(int, input().split())
A = [0] * N
cnt = 0
for i, x in enumerate(input().split()):
  A[i] = int(x) % M
  if A[i] == 0:
    cnt += 1
for i in range(N):
  sumA = A[i]
  for j in range(i + 1, N):
    sumA += A[j]
    sumA %= M
    if sumA == 0:
      cnt += 1
print(cnt)