'use strict';
(function(input){
  input=input.trim().split(/\n+/);
  input=input.map(str=>str.split(/\s+/).map(x=>x-0));
  const N=input[0][0];
  const arr=input[1].sort((a,b)=>a-b);
  const ans=[];
  var u=arr.length-1,d=0,p=N%2;
  var x,y,c;
  if(p===0){
    x=arr[u];
    y=arr[d];
  }else{
    x=arr[d];
    y=arr[u];
  }
  c=x-y;
  ans.push(x+' '+y);
  u--;
  d++;
  p=(p+1)%2;
  while(u>=d){
    if(p===0){
      x=arr[u];
      y=c;
      c=x-y;
      u--;
      ans.push(x+' '+y);
    }else{
      x=arr[d];
      y=c;
      c=x-y;
      d++;
      ans.push(x+' '+y);
    }
  }
  ans.unshift(c);
  console.log(ans.join('\n'));
})(require('fs').readFileSync('/dev/stdin','utf8'));