cnt = 0 result = 0 box = gets.chomp.to_i n = gets.chomp.to_i wide = gets.split.map(&:to_i) wide.sort.each do |num| result = num += num if result >= box if cnt == 0 cnt += 1 break else break end end cnt += 1 end puts cnt