### constant

SUM_W = 10

### subroutines

def count_manju(w, manju)
  if w == 0
    return ($cmcache[0][manju] = 1 + count_manju(SUM_W, manju))
  end

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

  max_count = 0
  n = manju.length

  for k in (0...n)
    mj = manju[k]

    if w >= mj
      manju0 = manju.clone
      manju0.delete_at k
      c = count_manju(w - mj, manju0)
      max_count = c if max_count < c
    end
  end

  $cmcache[w][manju] = max_count
end

### main

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

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

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

  c = count_manju(SUM_W, manju)
  puts c
end