n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
sum = []
count = 0
0.upto(n-1) do |i|
  s = a[0..i].reduce(:+)
  sum.push s
  count += 1 if s % m == 0
end
(1..(n-1)).each do |i|
  (i..(n-1)).each do |j|
    sum[j] -= a[i-1]
    count += 1 if sum[j] % m == 0
  end
end
puts count
