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

A.map! {|box| box%M}

choise = 0
# length 3 i 0
A.each_with_index do |num,i|
  count = num
  if count % M == 0
    choise = choise + 1
  end
  i.upto(A.length-1) do |j|
    if j != A.length-1
      count = count + A[j+1].to_i
      if count % M == 0
        choise = choise + 1
      end
    end
  end
end

p choise
