N,M = (int(i) for i in input().split())  
A = [int(i) for i in input().split()]

a = 0
sum_A = {}

for g in range(N):
	a += A[g]
	amari = a%M
	if amari in sum_A.keys():
		sum_A[amari] += 1
	else:
		sum_A[amari] = 1

ans = sum_A[0]
for l in range(len(sum_A)):
	if sum_A[list(sum_A)[l]] >= 2:
		ans += (sum_A[list(sum_A)[l]]-1)*sum_A[list(sum_A)[l]]/2
print(int(ans))