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

rui=[]
(0..n-1).each do |i|
  rui[i+1]=(rui[i]+a[i])%m
end

arr={}
(0..n).each do |i|
  t=rui[i]
  if arr.key?(t)
    arr[t]+=1
  else
    arr[t]=1
end

ans=0
arr.each do |k,v|
  if v>1
    ans+=v*(v-1)/2
  end
end

puts ans
  