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) {
    a.sort();

    auto ps = new Stack!(long);
    auto ns = new Stack!(long);
    foreach (x; a) {
        if (x >= 0) ps.push(x);
        else ns.push(x);
    }

    if (ps.empty) {
        ps.push(ns.pop());
    }
    else if (ns.empty) {
        ns.push(ps.pop());
    }

    long[][] steps;
    while (ps.size > 1 || ns.size > 1) {
        if (ps.size > ns.size) {
            long x = ns.pop();
            long y = ps.pop();
            ns.push(x - y);
            steps ~= [x, y];
        }
        else {
            long x = ps.pop();
            long y = ns.pop();
            ps.push(x - y);
            steps ~= [x, y];
        }
    }

    long x = ps.top;
    long y = ns.top;
    steps ~= [x, y];
    long ans = x - y;
    writeln(ans);
    foreach (s; steps) {
        writeln(s[0], " ", s[1]);
    }
}

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

class Stack(T) {
    private DList!(T) _dlist;
    private ulong _size;

    this(T[] ary) {
        _dlist = DList!(T)(ary);
        _size = ary.length;
    }

    this() {
        _dlist = DList!(T)();
        _size = 0;
    }

    void push(T x) {
        _dlist.insertBack(x);
        _size++;
    }

    T pop() {
        T x = _dlist.back;
        _dlist.removeBack();
        _size--;
        return x;
    }

    @property T top() {
        return _dlist.back;
    }

    @property ulong size() {
        return _size;
    }

    @property bool empty() {
        return _dlist.empty;
    }
}
