N, M = map(int, input().split())		# 5 7
A = list( map(int, input().split()) )	# 1 2 3 4 5 ...

A = list(map(lambda x: x%M, A))

ANS=[]

X=[]
Y=[]
count=0

for a in A:
	Y=[a] + list(map(lambda x: x+a, X))
	X=list(Y)
#	ANS.append(Y)
	count+=list(map(lambda x: x%M,Y)).count(0)

#for Z in ANS:
#	for z in Z:
#		if (z%M==0): count+=1

print(count)


