box_len, num_ch = gets.split(' ').map(&:to_i)
boxes = gets.split(' ').map{|n| (n.to_i)%num_ch }
result = 0

(0...boxes.length).each do |len|
  sum = boxes[0...len].inject(:+)
  (0...(boxes.length - len)).each do |i|
    sum -= boxes[i]
    sum += boxes[i + len]
    result += 1 if sum % num_ch == 0
  end
end
puts result