#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[N];
    bool pl = false;
    bool mn = false;
    bool zr = false;
    REP(i, 0, N) {
        cin >> A[i];
        if (A[i] > 0) {
            pl = true;
        } else if (A[i] < 0) {
            mn = true;
        } else {
            zr = true;
        }
    }
    sort(A, A + N);
    vector<ll> pvec, mvec, zvec;
    REP(i, 0, N) {
        if (A[i] > 0) {
            pvec.push_back(A[i]);
        } else if (A[i] < 0) {
            mvec.push_back(A[i]);
        } else {
            zvec.push_back(A[i]);
        }
    }
    ll ans = 0;
    ll plen = pvec.size();
    ll mlen = mvec.size();
    ll zlen = zvec.size();
    if (zr || (pl && mn)) {
        REP(i, 0, N) {
            ans += abs(A[i]);
        }
        cout << ans << endl;
        if (zr) {
            ll pre = 0;
            if (zvec.size() >= 2) {
                REP(i, 0, zvec.size() - 1) {
                    cout << 0 << " " << 0 << endl;
                }
            }
            if (plen > 0) {
                REP(i, 0, plen - 1) {
                    cout << pre << " " << pvec[i] << endl;
                    pre -= pvec[i];
                }
                cout << pvec[plen - 1] << " " << pre << endl;
                pre = pvec[plen - 1] - pre;
            }
            REP(i, 0, mlen) {
                cout << pre << " " << mvec[i] << endl;
                pre -= mvec[i];
            }
            return 0;
        } else {
            ll pre = mvec[0];
            REP(i, 1, plen) {
                cout << pre << " " << pvec[i] << endl;
                pre -= pvec[i];
            }
            cout << pvec[0] << " " << pre << endl;
            pre = pvec[0] - pre;
            REP(i, 1, mlen) {
                cout << pre << " " << mvec[i] << endl;
                pre -= mvec[i];
            }
            return 0;
        }
    } else {
        if (pl) {
            ans -= A[0];
            REP(i, 1, N) {
                ans += A[i];
            }
            cout << ans << endl;
            ll pre = pvec[0];
            REP(i, 1, plen - 1) {
                cout << pre << " " << pvec[i] << endl;
                pre -= pvec[i];
            }
            cout << pvec[plen - 1] << " " << pre << endl;
        } else {
            ans += A[N - 1];
            REP(i, 0, N - 1) {
                ans -= A[i];
            }
            cout << ans << endl;
            ll pre = mvec[mlen - 1];
            REP(i, 0, mlen - 1) {
                cout << pre << " " << mvec[i] << endl;
                pre -= mvec[i];
            }
        }
    }
}


Measured memory_bytes: 3576