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

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(long[] a) {
    a.sort();

    long[][] steps;
    long ans = 0;
    for (int i = 1; i < a.length; i++) {
        if (i == a.length - 1) {
            long x = a[i - 1];
            long y = a[i];
            steps ~= [y, x];
            ans = y - x;
        }
        else {
            long x = a[i - 1];
            long y = a[i];
            steps ~= [x, y];
            a[i] = x - y;
        }
    }

    writeln(ans);
    foreach (s; steps) {
        writeln(s[0], " ", s[1]);
    }
}

void main() {
    readint;
    auto a = reads!long;
    calc(a);
}
