n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).map { |k| k % m }

min_ranges = {}
(0..(n - 1)).each do |i|
  sum = 0
  (i..(n - 1)).each do |j|
    sum += a[j]
    if (sum % m).zero?
      min_ranges[i] = j
      break
    end
  end
end

arr = [0] * n
(n - 1).downto(0) do |i|
  arr[i] = if min_ranges.key?(i)
             if (min_ranges.fetch(i) + 1) < n
               arr[min_ranges.fetch(i) + 1] + 1
             else
               1
             end
           else
             0
           end
end

puts arr.inject(:+)
