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
p (0..N).to_a.combination(2)
    .select {|i,j|(cum[j]-cum[i])%M==0}
    .size
