num_ch = gets.split(' ')[1].to_i
boxes = gets.split(' ').map(&:to_i)

sum = 0
cnt_list = Array.new(num_ch).map{0}
boxes.each do|box|
  sum += box
  sum %= num_ch
  cnt_list[sum] += 1
end

puts(cnt_list.inject(0){|sum, c| sum + c*(c - 1)/2 } + cnt_list[0])
