#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a[ohara],b[ohara],c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
queue<ll> mainas;
queue<ll> plu;
vector<P> kou;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n)b[i]=a[i];
    sort(b,b+n);
    if(n==2){
        Cout(b[1]-b[0]);
        rep(i,n-1){
            cout<<b[1]<<" "<<b[0]<<"\n";
        }
        return 0;
    }
    if(b[0]>0){
        rep(i,n){
            if(i==0)ans-=b[i];
            else ans+=b[i];
        }
    }
    else if(b[n-1]<0){
        rep(i,n){
            if(i==n-1)ans+=b[i];
            else ans+=abs(b[i]);
        }
    }
    else{
        rep(i,n)ans+=abs(b[i]);
    }
    Cout(ans);
    rep(i,n){
        if(a[i]<0)tmp++,mainas.push(a[i]);
        else if(a[i]>0)tmpp++,plu.push(a[i]);
        else cnt++;
    }
    if(cnt!=0){
        if(tmp<tmpp){
            tmp+=cnt;
            rep(i,cnt)mainas.push(0);
        }
        else if(tmp>tmpp){
            tmpp+=cnt;
            rep(i,cnt)plu.push(0);
        }
        else{
            tmp+=1;
            tmpp+=cnt-1;
            mainas.push(0);
            rep(i,cnt-1)plu.push(0);
        }
    }
    if(cnt==n-1){
        int okk=0;
        rep(i,n){
            if(b[i]!=0){
                if(b[i]<0){okk=1;pos=b[i];}
            }
        }
        if(okk){
            cout<<0<<" "<<pos<<"\n";
            ans=-pos;
            rep(i,n-2){
                cout<<ans<<" "<<0<<"\n";
            }
            return 0;
        }
    }
    if(b[0]>0){
        ll now;
        cout<<b[0]<<" "<<b[1]<<"\n";
        now=b[0]-b[1];
        rrep(i,2,n-1){
            cout<<now<<" "<<b[i]<<"\n";
            now=now-b[i];
        }
        cout<<b[n-1]<<" "<<now<<"\n";
        now=b[n-1]-now;
        return 0;
    }
    else if(b[n-1]<0){
        reverse(b,b+n);
        ll now;
        cout<<b[0]<<" "<<b[1]<<"\n";
        now=b[0]-b[1];
        rrep(i,1,n-1){
            cout<<now<<" "<<b[i+1]<<"\n";
            now=now-b[i+1];
        }
        return 0;
    }
    else if(tmpp==1){
        ll now;
        cout<<plu.front()<<" "<<mainas.front()<<"\n";
        now=plu.front()-mainas.front();
        mainas.pop();
        while(!mainas.empty()){
            cout<<now<<" "<<mainas.front()<<"\n";
            now=now-mainas.front();
            mainas.pop();
        }
        return 0;
    }
        ll p;
        m=mainas.front();
        p=plu.front();
        mainas.pop();
        plu.pop();
        kou.push_back({m,p});
        ll now;
        now=m-p;
        pos=Size(plu);
        rep(i,pos-1){
            p=plu.front();
            plu.pop();
            kou.push_back({now,p});
            now-=p;
        }
        kou.push_back({plu.front(),now});
        now=plu.front()-now;
        while(!mainas.empty()){
            m=mainas.front();
            mainas.pop();
            kou.push_back({now,m});
            now-=m;
        }
        rep(i,Size(kou)){
            cout<<kou[i].fi<<" "<<kou[i].se<<"\n";
        }

    return 0;
}


Measured memory_bytes: 9332