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

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

ans = 0
for i in range(N):
  ans += sumA[i+1:].count(sumA[i])
  if sumA[i] == 0: ans += 1
print(ans)