import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

alias T = Tuple!(long, long);

void main() {
  int n;
  readf (" %d", &n);
  auto a = new int[n];
  foreach (t; 0 .. n) {
    readf (" %d", &a[t]);
  }
  a.sort ();
  int m = n / 2;
  auto b = new long[n];
  foreach (i; 0 .. n) b[i] = a[i];
  T[] r;
  int i = 0, j = m; 
  while (i < m && j < n - 1) {
    r ~= tuple (b[i], b[j]); //x - y
    b[i] = b[i] - b[j];
    ++i;
    ++j;
  }
  foreach (k; 0 .. m) {
    r ~= tuple (b[n-1], b[k]);
    b[n-1] = b[n-1] - b[k];
  }
  writeln (b[n-1]);
  foreach (p; r) {
    writeln (p[0], ' ', p[1]);
  }
}
