#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



void Main()
{
    int n;cin>>n;
    VL plus,minus,zero;
    REP(i,n){
        LL a;cin>>a;
        if(a<0){
            minus.PB(a);
        }
        else if(a>0){
            plus.PB(a);
        }
        else{
            zero.PB(a);
        }
    }
    SORT_ASC(plus);
    SORT_ASC(minus);
    int n_minus=SIZE(minus);
    int n_plus=SIZE(plus);
    int n_zero=SIZE(zero);

    if(n==n_zero){
        cout<<0<<endl;
        REP(i,n-1){
            cout<<"0 0"<<endl;
        }
        return;
    }
    if(n_plus==0){
        if(n_zero!=0){
            cout<<-accumulate(ALL(minus),0LL)<<endl;
            REP(i,n_zero-1){
                cout<<"0 0"<<endl;
            }
            LL m=0;
            REP(i,n_minus){
                cout<<m<<" "<<minus[i]<<endl;
                m-=minus[i];
            }
        }
        else{
            cout<<-accumulate(ALL(minus),0LL)+minus[n-1]+minus[n-1]<<endl;
            LL m=minus[n-1];
            REP(i,n-1){
                cout<<m<<" "<<minus[i]<<endl;
                m-=minus[i];
            }
        }
    }
    else if(n_minus==0){
        if(n_zero!=0){
            cout<<accumulate(ALL(plus),0LL)<<endl;
            REP(i,n_zero-1){
                cout<<"0 0"<<endl;
            }
            LL m=0;
            REP(i,n_plus-1){
                cout<<m<<" "<<plus[i]<<endl;
                m-=plus[i];
            }
            cout<<plus[n_plus-1]<<" "<<m<<endl;
        }
        else{
            cout<<accumulate(ALL(plus),0LL)-plus[0]-plus[0]<<endl;
            LL m=plus[0];
            REP(i,n-2){
                cout<<m<<" "<<plus[i+2]<<endl;
                m-=plus[i+2];
            }
            cout<<plus[1]<<" "<<m<<endl;
        }
    }
    else{
        if(n_zero!=0){
            cout<<accumulate(ALL(plus),0LL)-accumulate(ALL(minus),0LL)<<endl;
            REP(i,n_zero-1){
                cout<<"0 0"<<endl;
            }
            LL m=minus[0];
            REP(i,n_plus){
                cout<<m<<" "<<plus[i]<<endl;
                m-=plus[i];
            }
            cout<<"0 "<<m<<endl;
            m*=-1;
            REP(i,n_minus-1){
                cout<<m<<" "<<minus[i+1]<<endl;
                m-=minus[i+1];
            }
        }
        else{
            cout<<accumulate(ALL(plus),0LL)-accumulate(ALL(minus),0LL)<<endl;
            LL m=minus[0];
            REP(i,n_plus-1){
                cout<<m<<" "<<plus[i]<<endl;
                m-=plus[i];
            }
            cout<<plus[n_plus-1]<<" "<<m<<endl;
            m=plus[n_plus-1]-m;
            REP(i,n_minus-1){
                cout<<m<<" "<<minus[i+1]<<endl;
                m-=minus[i+1];
            }
        }
    }

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 2804