#include<bits/stdc++.h>
using namespace std;
typedef long long ll;



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

    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    ll ans = a[n-1];
    for(int i=1;i<n-1;i++){
        if(a[i]<=0) ans -= a[i];
        else ans += a[i];
    }
    ans -= a[0];
    cout << ans <<endl;
    ll now = a[n-1];
    for(int i=1;i<n-1;i++){
        if(a[i]<=0){
            cout << now <<" "<<a[i] << endl;
            now -= a[i];
        }
    }
    ll nx = a[0];
    for(int i=1;i<n-1;i++){
        if(a[i]>0){
            cout << nx <<" "<< a[i] << endl;
            nx -= a[i];
        }
    }

    cout << now << " " << nx <<endl;


    
}