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 == 0
      min_ranges[i] = j
      break
    end
  end
end

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

puts arr.sum
