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 ();
  auto b = a.map!(to!long).array;
  T[] r;
  foreach (i; 1 .. n - 1) {
    if (b[i] > 0) {
      r ~= tuple (b[0], b[i]);
      b[0] -= b[i];
    } else {
      r ~= tuple (b[n-1], b[i]);
      b[n-1] -= b[i];
    }
  }
  r ~= tuple (b[n-1], b[0]);
  writeln (b[n-1] - b[0]);
  foreach (p; r) {
    writeln (p[0], ' ', p[1]);
  }
}
