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

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) {
    writeln(a);
    long ans = 0;
    long[][] steps;
    for (int i = 1; i < a.length; i++) {
        if (i == a.length - 1) {
            long x = a[i - 1];
            long y = a[i];
            if (y > 0) {
                steps ~= [y, x];
                ans = y - x;
            }
            else {
                steps ~= [x, y];
                ans = x - y;
            }
        }
        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 calc(long[] a) {
    long[] ps;
    long[] ns;

    foreach (x; a) {
        if (x >= 0) ps ~= x;
        else ns ~= x;
    }

    ps.sort();
    ns.sort();

    if (ps.length == 0) {
        ns.reverse();
        _calc(ns);
        return;
    }
    else if (ns.length == 0) {
        _calc(ps);
        return;
    }

    long[][] steps;
    int p = 0;
    int n = 0;
    auto pp = DList!long(ps);
    int psize = cast(int)ps.length;
    auto nn = DList!long(ns);
    int nsize = cast(int)ns.length;
    long ans = 0;
    while (psize > 0 && nsize > 0) {
        if (psize == 1 && nsize == 1) {
            long x = pp.front;
            long y = nn.front;
            ans = x - y;
            steps ~= [x, y] ;
            break;
        }

        if (psize > nsize) {
            long x = pp.front; pp.removeFront();
            long y = nn.front; nn.removeFront();
            steps ~= [y, x];
            nn.insertBack(y - x);
            psize--;
        }
        else {
            long x = pp.front; pp.removeFront();
            long y = nn.front; nn.removeFront();
            steps ~= [x, y];
            pp.insertBack(x - y);
            nsize--;
        }
    }

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

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