(* O(n) *)
let n = Scanf.scanf " %d" @@ (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let p = ref @@ -1
let xys = ref []
let _ =
  Array.sort (-) a_s;
  let i = ref 0 in while !p < 0 && !i < n do if a_s.(!i) >= 0 then p := !i; incr i done;
  if !p = -1 then p := n - 1
  else if !p = 0 then p := 1;
  for i = !p to n - 2 do
    xys := (a_s.(0), a_s.(i)) :: !xys;
    a_s.(0) <- a_s.(0) - a_s.(i)
  done;
  for i = 0 to !p - 1 do
    xys := (a_s.(n - 1), a_s.(i)) :: !xys;
    a_s.(n - 1) <- a_s.(n - 1) - a_s.(i)
  done;
  Printf.printf "%d\n" a_s.(n - 1);
  List.rev !xys |> List.iter @@ fun (x, y) -> Printf.printf "%d %d\n" x y