a = input().split()
n = int(a[0])
m = int(a[1])
 
a = input().split(' ')
a = [int(i)%m for i in a]
 
summatrix = [[0 for i in range(n)] for i in range(n)]
output = 0
 
for i in range(n):
	for j in range(i, n):
		if i != 0:
			summatrix[i][j] = (summatrix[i - 1][j - 1] + a[i] + a[j])%m
		if i == 0 and j == 0:
			summatrix[0][0] = a[0] %m
		else:
			summatrix[i][j] = (summatrix[i][j - 1] + a[j])% m
		if summatrix[i][j] == 0:
			output += 1
		
print (output)