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

cnt = 0
sum = 0
tmp = []
for i in range(N):
	sum += A[i]
	q = sum%M
	if q != 0:
		cnt += tmp.count(q)
		tmp.append(q)
	else:
		tmp.append(q)
		cnt += tmp.count(q)
print(cnt)