def sum_roop(yen1, yen2, num1, num2, list, sum) for i in 0...yen1 do list << sum += num1 for j in 0...yen2 do list << sum += num2 end end list end one_yen, five_yen = gets.chomp.split(" ").map(&:to_i) list = Array.new sum = 0 (0...one_yen).each{ list << sum += 1} sum = 0 (0...five_yen).each{ list << sum += 5} sum = 0 if five_yen > one_yen sum_roop(one_yen, five_yen, 1, 5, list, sum) else sum_roop(five_yen, one_yen, 5, 1, list, sum) end puts list.uniq.sort()