n, m = gets.strip.split.map(&:to_i)
a = gets.strip.split.map(&:to_i)

cum_a = [a.first]
(1...n).each do |i|
  cum_a[i] = cum_a[i-1]+a[i]
end
cum_a.unshift(0)

result=0
n.times do |l|
  la = cum_a[l]
  (l+1..n).each do |r|
    #p [(cum_a[r]-la)%m, cum_a[r], la]
    result+=1 if ((cum_a[r]-la)%m).zero?
  end
end

#p"--"
#p a
#p cum_a
p result
