io = STDIN
N,M=io.gets.split.map(&:to_i)
ar=io.gets.split.map(&:to_i)

cum=Array.new(N+1,0)
N.times do |i|
  cum[i+1]+=cum[i]+ar[i]
end
ans=0
(0..N-1).each do |i|
  (i+1..N).each do |j|
    ans+=1 if (cum[j]-cum[i])%M==0
  end
end
p ans
