def comb2(n)
  if n < 2
    return 0
  else
    (n * (n - 1)) >> 1
  end
end

N, M = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)
sum_modM_idx = {}

sum_modM = 0
A.each do |a|
  sum_modM += a
  sum_modM %= M
  sum_modM_idx[sum_modM] = 0 unless sum_modM_idx.key?(sum_modM)
  sum_modM_idx[sum_modM] += 1
end

ans = sum_modM_idx[0]
sum_modM_idx.each_value do |n|
  ans += comb2(n)
end
puts ans