#include <bits/stdc++.h>

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    int plus = 0, minus = 0, zero = 0;
    REP(i, N) {
        cin >> A[i];
        if (A[i] > 0) {
            plus++;
        } else if (A[i] < 0) {
            minus++;
        } else {
            zero++;
        }
    }
    int A_sum = accumulate(all(A), 0);
    if (minus == 0) {
        if (N == 2) {
            int M1 = A[0] - A[1];
            int M2 = A[1] - A[0];
            if (M1 >= M2) {
                cout << M1 << '\n';
                cout << A[0] << ' ' << A[1] << '\n';
            } else {
                cout << M2 << '\n';
                cout << A[1] << ' ' << A[0] << '\n';
            }
            return;
        }
        priority_queue<int, vector<int>, greater<int>> q;
        REP(i, N) {
            q.push(A[i]);
        }
        int x, y;
        x = q.top();
        q.pop();
        int A_min = x;
        int M = A_sum - 2 * A_min;
        cout << M << '\n';
        REP(i, N - 2) {
            y = q.top();
            q.pop();
            cout << x << ' ' << y << '\n';
            x = x - y;
        }
        y = x;
        x = q.top();
        q.pop();
        cout << x << ' ' << y << '\n';
        cout << flush;
        assert(x - y == M);
    } else if (plus == 0) {
        priority_queue<int> q;
        REP(i, N) {
            q.push(A[i]);
        }
        int x, y;
        x = q.top();
        q.pop();
        int A_max = x;
        int M = -A_sum + 2 * A_max;
        cout << M << '\n';
        REP(i, N - 1) {
            y = q.top();
            q.pop();
            cout << x << ' ' << y << '\n';
            x = x - y;
        }
        assert(x == M);
    } else {
        sort(all(A));
        int A_min = A[0];
        int A_max = A[N - 1];
        int M = 0;
        REP(i, N) M += abs(A[i]);
        cout << M << '\n';
        int x1, y1, x2, y2;
        x1 = A_max;
        x2 = A_min;
        FOR(i, 1, N - 1) {
            if (A[i] >= 0) {
                y2 = A[i];
                cout << x2 << ' ' << y2 << '\n';
                x2 = x2 - y2;
            } else {
                y1 = A[i];
                cout << x1 << ' ' << y1 << '\n';
                x1 = x1 - y1;
            }
        }
        int x = x1;
        int y = x2;
        cout << x << ' ' << y << '\n';
        assert(x - y == M);
    }
    cout << flush;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 2680