#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N; cin >> N;
    vector<ll> A;
    ll cnt_m = 0, cnt_p = 0, cnt_z = 0;;

    ll s = INT_MAX;
    ll t = -INT_MAX;
    ll sum = 0;

    for (int i = 0;i < N;i++){
        ll a; cin >> a;
        if(a < 0){
            t = max(t,a);
            cnt_m++;
        }else if(a > 0){
            s = min(s,a); 
            cnt_p++;
        }else{ cnt_z++; s = 0;t = 0;}
        sum += abs(a);
        A.push_back(a);
    }

    sort(A.begin(),A.end());

    if(cnt_m == 0){
        cout << sum - A[0]*2 << endl;
        ll tmp = A[0];
        for (int i = 1;i < N-1;i++){
            cout << tmp << " " << A[i] << endl;
            tmp -= A[i];
        }
        cout << A[N-1] << " " << tmp << endl;
    }else if(cnt_p == 0){
        cout << sum + A[N-1]*2 << endl;
        ll tmp = A[N-1];
        for (int i = 0;i < N-1;i++){
            cout << tmp << " " << A[i] << endl;
            tmp -= A[i];
        }
    }else{
        cout << sum  << endl;
        ll tmp = A[0];
        for (int i = N-1;i > cnt_m+cnt_z;i--){
            cout << tmp << " " << A[i] << endl;
            tmp -= A[i];
        }
        cout << A[cnt_m+cnt_z] << " " << tmp << endl;;
        tmp = A[cnt_m+cnt_z]-tmp;
        for (int i = 1;i < cnt_m+cnt_z;i++){
            cout << tmp << " " << A[i] << endl;
            tmp -= A[i];
        }
    }


    /* if(cnt_z != 0){
        cout << sum << endl;
        if(cnt_p == 0){
            ll tmp = 0;
            for (int i = 0;i < cnt_m;i++){
                cout << tmp << " " << A[i] << endl;
                tmp -= A[i];
            }
            for (int i = cnt_m;i < N-1;i++){
                cout << tmp << " " << A[i] << endl;
            }
        }else{
            ll tmp = A[N-1];
            for (int i = 0;i < cnt_m;i++){
                cout << tmp << " " << A[i] << endl;
                tmp -= A[i];
            }
            ll tmp2 = 0;
            for (int i = cnt_m+1;i < N-1;){
                cout << tmp2 << " " << A[i] << endl;
                tmp2 -= A[i];
            }
            cout << tmp << " " << tmp2 << endl;
        }
    }else{

        if(s == INT_MAX && t == -INT_MAX){
            cout << 0 << endl;
            for (int i = 0;i < N-1;i++){
                cout << 0 << " " << 0 << endl;
            }
        }else if(s == INT_MAX){
            cout << sum-2*abs(t) << endl;
            ll tmp = A[N-1];
            for (int i = 0;i < N-1;i++){
                cout << tmp << " " << A[i] << endl;
                tmp -= A[i];
            }
        }else if(t == -INT_MAX){
            cout << sum-2*abs(s) << endl;
            if(N == 2){
                cout << A[1] << " " << A[0] << endl;
            }else{
                ll tmp = A[0];
                for (int i = 0;i < N-2;i++){
                    cout << tmp << " " << A[i+1] << endl;
                    tmp -= A[i+1];
                }
                cout << A[N-1] << " " << tmp << endl;
            }
        }else if(abs(s) > abs(t)){
            cout << sum-2*abs(t) << endl;
            ll tmp = A[0];
            for (int i = cnt_m+cnt_z;i < N;i++){
                cout << tmp << " " << A[i] << endl;
                tmp -= A[i];
            }
            cout << A[cnt_m-1] << " " << tmp << endl;
            tmp -= A[cnt_m-1];
            for (int i = 1;i < cnt_m+cnt_z;i++){
                if(i == cnt_m-1) continue;
                cout << tmp << " " << A[i] << endl;
                tmp -= A[i];
            }
        }else{
            cout << sum-2*abs(s) << endl;
            ll tmp = A[0];
            for (int i = cnt_m+cnt_z+1;i < N;i++){
                cout << tmp << " " << A[i] << endl;
                tmp -= A[i];
            }
            cout << A[cnt_m+cnt_z] << " " << tmp << endl;
            tmp = A[cnt_m+cnt_z] - tmp;
        }
    }*/

    return 0;

}

Measured memory_bytes: 2804