let () =
  let x,  k = Scanf.scanf "%d %d %d %d" (fun a b c k -> [a;b;c], k) in
  let x' = List.rev (List.sort (-) x) in
  let y = (List.hd x') * 2 * k in
  let res = y + List.fold_left (+) 0 (List.tl x') in
  Printf.printf "%d\n" res
    
      
