use std::io::Read; use std::cmp::{max, min}; fn main() { let mut all_data = String::new(); std::io::stdin().read_to_string(&mut all_data).ok(); let all_data: Vec<&str> = all_data.trim().split('\n').map(|i| i.trim()).collect(); let n: usize = all_data.iter().next().unwrap().parse::().unwrap(); let x: Vec = all_data.iter().skip(1).next().unwrap().split_whitespace().map(|i| i.parse::().unwrap()).collect(); let y: Vec = all_data.iter().skip(2).next().unwrap().split_whitespace().map(|i| i.parse::().unwrap()).collect(); let minidx2val: (usize, usize) = x.iter().zip(y.iter()).map(|pair| pair.0 + pair.1).enumerate().min_by_key(|pair| pair.1).unwrap(); println!("{}", minidx2val.1); for i in 0..(n+2) { if i == 0 { println!("{}", 0); } else if i == n+1 { println!("{}", minidx2val.1); } else { println!("{}", max(if minidx2val.1 < y[i-1] { 0 } else { minidx2val.1 - y[i-1] }, min(x[i-1], x[minidx2val.0]))); } } }