n,m=gets.split.map &:to_i
a=gets.split.map(&:to_i).map{|y|y=y%m}
ans=0
x=0
for i in 0..n-1
  x=a[i]
  j=i
  c=0
  while j<n
    if x%m==0
      c+=1
      x=a[j+1]
    elsif j<n-1
      x+=a[j+1]
    end
    j+=1
  end
  ans+=c
end
puts ans