N, M = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)

cnt = 0
(0...N).each do |i|
  (i...N).each do |j|
    cnt +=1 if a[i..j].reduce{ |x, s| s += x} % M == 0
  end
end

puts cnt 