n, k = gets.split.map &:to_i
as =  gets.split.map &:to_i

sums = [0]

sum = 0

as.each{ |x|
	sum += x
	sums << sum
}

count = 0

print sums
puts

(0..n).to_a.combination(2).each{ |a,b|
#	print a, b
##	puts

	if (sums[b] - sums[a]) % k == b - a then
		count += 1
	end
}

puts count
