def lscan; gets.split.map(&:to_i); end n = gets.to_i xy = [lscan,lscan].transpose mx = xy.map{|x,y| x+y}.min p mx p 0 puts xy.map{|x,y| [0, [mx-y, x].min].max} p mx