$dp = {}
$cnt = 0

def rec(i,j)
  return $dp[[i,j]] if $dp[[i,j]]
  if i == j
    if $arr[i] % $m == 0
      $cnt += 1
    end
    return $dp[[i,j]] = $arr[i]
  else
    ret = rec(i, j-1) + rec(i+1, j) 
    ret -= rec(i+1, j-1) if i+1 <= j-1

    if ret % $m == 0
      $cnt += 1
    end
    return $dp[[i,j]] = ret
  end
end

n,$m = gets.split(' ').map(&:to_i)
$arr = gets.split(' ').map(&:to_i)

rec(0, n-1)
puts $cnt