### constant

SUM_W = 10

### subroutines

def count_manju(k, w, bits)
  if k >= $n
    return ($cmcache[0][bits] = (w == 0) ? 1 + count_manju(0, SUM_W, bits) : 0)
  end

  return $cmcache[w][bits] if ! $cmcache[w][bits].nil?

  max_count = count_manju(k + 1, w, bits)

  mj = $manju[k]
  b = (1 << k)

  if w >= mj && (bits & b) == 0
    c = count_manju(k + 1, w - mj, bits | b)
    max_count = c if max_count < c
  end

  $cmcache[w][bits] = max_count
end

### main

while true
  $n = gets.strip.to_i
  break if $n == 0

  $manju = gets.strip.split(' ').map{|s| s.to_i }
  #p $manju

  $cmcache = (SUM_W + 1).times.map{{}}

  c = count_manju(0, SUM_W, 0)
  puts c
end