N = gets.to_i X = gets.split.map(&:to_i) Y = gets.split.map(&:to_i) ans = [] ans << 0 min_v = Float::INFINITY X.zip(Y) do |x, y| v = x + y min_v = v if min_v > v end X.zip(Y) do |x, y| ans << [x, min_v].min end ans << min_v puts min_v puts ans