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