N, M = map(int, input().split())
L = list(map(int, input().split()))
 
if N == 1:
	if L[0]%M == 0:
		print(1)
		exit()
	else:
		print(0)
		exit()

for i in range (0, N):
	L[i] = L[i]%M

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

L = sorted(L)
 
alreadythere = []
 
for i in range (0, N):
	if alreadythere.count(L[i])>0 or L[i] == 0:
		continue
	else:
		alreadythere.append(L[i])
		V = L[i]
		D = L.count(L[i])
		count+= int(D*(D-1)/2)

V = L.count(0)
count+= V+int(V*(V-1)/2)
 
print(count)