N,M = map(int,input().split())
A = list(map(int, input().split()))
B = [0] * N
ans = 0

A[0] = A[0]%M
for i in range(N-1):
  A[i+1] = ( A[i] + A[i+1] )%M

B[0] = A[0]
for i in range(N-1):
  B[i+1] = ( B[i] + A[i+1] )%M

ans = A.count(0)
for i in range(N-1):
  ans = ans + A.count(B[i])

print(ans)