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