n,m = map(int,input().split())
A = [int(i)%m for i in input().split()]  
S = [0]*n
S[0] = A[0]
for i in range(n):
	S[i] = (S[i-1]+A[i])%m
D = dict()
for s in S:
	if s in D:D[s] += 1
	else:D[s] = 1
res = D[0]
for v in D.values():
	res += v*(v-1)//2
print(res)