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

mods = [1] + [0] * (M - 1)
sum = 0
N.times do |i|
  sum += A[i]
  mods[sum % M] += 1
end

puts mods.collect{|i| i * (i - 1) / 2}.inject(:+)