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

sum = 0
s = set()
t = []
for i in range(N):
	sum += A[i]
	s.add(sum%M)
	t.append(sum%M)

def calc(n):
	return int((n + 1) * n / 2)

cnt = 0
for i in s:
	st = t.count(i)
	if st <= 1:
		continue
	if i == 0:
		cnt += calc(st)
	else:
		cnt += calc(st-1)
print(cnt)