#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N;
vector<ll> A;

vector<ll> neg, pos;

vector< pair<ll, ll> > ans_manu;

ll manu() {
    // pos をひとつ取り出す
    ll cand = pos[pos.size()-1];
    pos.pop_back();

    // neg をひとつにする
    while(neg.size() > 1) {
        ans_manu.push_back(make_pair(cand, neg[neg.size()-1]));
        cand -= neg[neg.size()-1];
        neg.pop_back();
    }

    pos.push_back(cand);
    cand = neg[neg.size()-1];
    neg.pop_back();
    assert(neg.size() == 0);
    // pos をひとつにする
    while(pos.size() > 1) {
        ans_manu.push_back(make_pair(cand, pos[pos.size()-1]));
        cand -= pos[pos.size()-1];
        pos.pop_back();
    }

    // さいごのひとつに cand を引く
    ans_manu.push_back(make_pair(pos[pos.size()-1], cand));
    return pos[pos.size()-1] - cand;
}

signed main()
{
    cin >> N;
    A.resize(N);
    REP(i, N) {
        cin >> A[i];
        if(A[i] < 0) {
            neg.push_back(A[i]);
        }
        else {
            pos.push_back(A[i]);
        }
    }
    sort(neg.begin(), neg.end(), greater<ll>());
    SORT(pos);

    ll ans = 0;
    if(neg.size() > 0 && pos.size() > 0) {
        ans = manu();
    }
    else if(neg.size() == 0) {
        if(N == 2) {
            ans = pos[1] - pos[0];
            ans_manu.push_back(make_pair(pos[1], pos[0]));
        }
        // すべてが同じ値
        else if(pos[0] == pos[pos.size()-1]) {
            if(N == 3) {
                ans = pos[0];
                ans_manu.push_back(make_pair(pos[0], pos[1]));
                ans_manu.push_back(make_pair(pos[1], 0));
            }
            else {
                ans_manu.push_back(make_pair(pos[0], pos[1]));
                ans_manu.push_back(make_pair(0, pos[0]));
                pos.pop_back();
                pos.pop_back();
                pos.pop_back();
                neg.push_back(-pos[0]);
                ans = manu();
            }
        }
        else {
            ll cand = pos[0] - pos[pos.size()-1];
            ans_manu.push_back(make_pair(pos[0], pos[pos.size()-1]));
            pos.pop_back();
            pos.erase(pos.begin());
            neg.push_back(cand);
            ans = manu();
        }
    }
    else if(pos.size() == 0) {
        if(N == 2) {
            ans = neg[0] - neg[1];
            ans_manu.push_back(make_pair(neg[0], neg[1]));
        }
        else if(neg[0] == neg[neg.size()-1]) {
            if(N == 3) {
                ans = -neg[0];
                ans_manu.push_back(make_pair(neg[0], neg[1]));
                ans_manu.push_back(make_pair(0, neg[1]));
            }
            else {
                ans_manu.push_back(make_pair(neg[0], neg[1]));
                ans_manu.push_back(make_pair(0, neg[0]));
                neg.pop_back();
                neg.pop_back();
                neg.pop_back();
                pos.push_back(-neg[0]);
                ans = manu();
            }
        }
        else {
            ll cand = neg[0] - neg[neg.size()-1];
            ans_manu.push_back(make_pair(neg[0], neg[neg.size()-1]));
            neg.pop_back();
            neg.erase(neg.begin());
            pos.push_back(cand);
            ans = manu();
        }
    }
    else {
        assert(false);
    }

    //assert(ans_manu.size() == N - 1);
    printf("%lld\n", ans);
    for(auto& p : ans_manu) {
        printf("%lld %lld\n", p.first, p.second);
    }
    return 0;
}


Measured memory_bytes: 5872