n=gets.to_i gets a=gets.split.map(&:to_i).sort s=0 p$$.times{|i|break(i)if s>n;s+=a[i]}