log = console.log;
var stdin = require("fs").readFileSync("/dev/stdin", "UTF-8");
var lines = stdin
  .split("\n")
  .filter(v => v !== "")
  .map(v => v.split(" ").map(Number));

var N = lines[0];
var A = lines[1];

A.sort((a, b) => a - b);

var processList = [];

while (A.length > 2) {
  var min = A.shift();
  var max = A.pop();
  processList.push(min+ " " + max);
  A.unshift(min - max);
}
processList.push(A[1]+ " " + A[0]);
log(A[1] - A[0]);
processList.forEach(v=>{
  log(v)
})