import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.List
import           Data.Maybe
import qualified Data.Sequence         as Seq

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  n <- getInt
  as <- getIntList
  let aseq = Seq.unstableSort $ Seq.fromList as
      a1 Seq.:< aseq' = Seq.viewl aseq
      aseq'' Seq.:> an = Seq.viewr aseq'

      assortAs ps ns sq | Seq.null sq = (ps, ns)
                        | otherwise =
                          let aj Seq.:< sq' = Seq.viewl sq
                          in
                            if aj > 0
                            then assortAs (aj:ps) ns sq'
                            else assortAs ps (aj:ns) sq'

      (ps, ns) = assortAs [an] [a1] aseq''

      ans = sum ps - sum ns

      printOps [a] [b] = putStrLn $ show a ++ " " ++ show b
      printOps (a:ps) (b:ns) = do putStrLn $ show b ++ " " ++ show a
                                  printOps ps (b-a:ns)

  print ans
  printOps ps ns