ones, fives = gets.chomp.split.map(&:to_i) list ,sum = Array.new, 0 1.upto(ones){ list << sum += 1 } sum = 0 1.upto(fives){list << sum += 5 } sum = 0 1.upto(ones){ list << sum += 1 list << sum += 5 if ones == fives 1.upto(fives){ list << sum += 5 } if ones < fives } sum = 0 1.upto(fives){ list << sum += 5 list << sum += 1 if ones == fives 1.upto(ones){ list << sum += 1 } if ones > fives } puts list.uniq.sort