let (inp,out) = (Scanf.Scanning.from_file "key.in", open_out "key.out");;
let (n,m) = Scanf.bscanf inp "%d %d\n" (fun a b -> (a,b));;

let rec merge res l =
  match (res,l) with
    ([],_) -> []
  | (r1::rs,l1::ls) when l1 <= r1 -> merge (List.map (Int64.add l1) res) ls
  | (r1::rs,_) -> r1 :: merge (List.map (Int64.add r1) rs) l;;

let rec gen n f = if n > 0 then f() :: gen (n-1) f else [];;

let src = gen n (fun () -> Scanf.bscanf inp " %Ld" (fun x -> x));; 
let buy = gen m (fun () -> Int64.one);;
let res = merge buy (List.sort (Int64.compare) src);;
List.iter (Printf.fprintf out "%Ld ") res;;

close_out out;;
