def distance_sum(a, l, r)
  current = l - 1
  sum = 0
  while current < r do
    sum += a[current]
    current += 1
  end
  sum
end


input = gets
input = input.split(' ').map(&:to_i)
n = input[0]
m = input[1]

input = gets
a = input.split(' ').map(&:to_i)

count = 0
for l in 1..n
  for r in l..n
    count += 1 if distance_sum(a, l, r) % m == 0
  end
end

puts count