#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
const int INF = 1145141919, MOD = 1e9 + 7;
const int64_t LINF = 8931145141919364364, LMOD = 998244353;
// const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
// const int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

int main() {
    int n; cin>>n;
    int64_t a[n];
    int zero=0;
    queue<int> pl,mi;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>0) pl.push(a[i]);
        else if(a[i]<0) mi.push(a[i]);
        else zero++;
    }
    vector<int> ansx,ansy;
    if(zero>0){
        if(pl.size()==0&&mi.size()==0){
            cout<<0<<endl;
            for(int i=0;i<n-1;i++){
                cout<<"0 0"<<endl;
            }
            return 0;
        }
        if(pl.size()==0&&mi.size()==1){
            int m=-mi.front();
            cout<<m<<endl;
            printf("0 %d\n", -m);
            zero--;
            while(zero--){
                printf("%d %d\n", m, 0);
            }
            return 0;
        }
        if(pl.size()==1&&mi.size()==0){
            int m=pl.front();
            cout<<m<<endl;
            while(zero--){
                printf("%d %d\n", m, 0);
            }
            return 0;
        }
        if(mi.size()==0){
            zero--;
            ansx.push_back(0);
            ansy.push_back(pl.front()); pl.pop();
            int m=-ansy[0];
            for(int i=0;i<(n-1)-zero-1;i++){
                if(i==(n-1)-zero-2){
                    int x=pl.front();
                    ansx.push_back(x); pl.pop();
                    ansy.push_back(m);
                    m=x-m;
                }else{
                    int x=pl.front();
                    ansx.push_back(m);
                    ansy.push_back(x); pl.pop();
                    m-=x;
                }
            }
            cout<<m<<endl;
            for(int i=0;i<(int)ansx.size();i++){
                printf("%d %d\n", ansx[i], ansy[i]);
            }
            while(zero--){
                printf("%d %d\n", m, 0);
            }
        }else if(pl.size()==0){
            zero--;
            ansx.push_back(0);
            ansy.push_back(mi.front()); mi.pop();
            int m=-ansy[0];
            for(int i=0;i<(n-1)-zero-1;i++){
                int y=mi.front();
                ansx.push_back(m);
                ansy.push_back(y); mi.pop();
                m-=y;
            }
            cout<<m<<endl;
            for(int i=0;i<(int)ansx.size();i++){
                printf("%d %d\n", ansx[i], ansy[i]);
            }
            while(zero--){
                printf("%d %d\n", m, 0);
            }
        }else{
            int m=mi.front(); mi.pop();
            while(pl.size()){
                int x=m;
                int y=pl.front(); pl.pop();
                if(pl.size()==0) swap(x,y);
                ansx.push_back(x);
                ansy.push_back(y);
                m=x-y;
            }
            while(mi.size()){
                int x=m;
                int y=mi.front(); mi.pop();
                ansx.push_back(x);
                ansy.push_back(y);
                m=x-y;
            }
            cout<<m<<endl;
            for(int i=0;i<(int)ansx.size();i++){
                printf("%d %d\n", ansx[i], ansy[i]);
            }
            while(zero--){
                printf("%d %d\n", m, 0);
            }
        }
    }else{
        if(mi.size()==0){
            sort(a,a+n);
            ansx.push_back(a[0]);
            ansy.push_back(a[1]);
            int m=a[0]-a[1];
            for(int i=2;i<n;i++){
                if(i==n-1){
                    ansx.push_back(a[i]);
                    ansy.push_back(m);
                    m=a[i]-m;
                }else{
                    ansx.push_back(m);
                    ansy.push_back(a[i]);
                    m-=a[i];
                }
            }
            cout<<m<<endl;
            for(int i=0;i<(int)ansx.size();i++){
                printf("%d %d\n", ansx[i], ansy[i]);
            }
        }else if(pl.size()==0){
            sort(a,a+n); reverse(a,a+n);
            ansx.push_back(a[0]);
            ansy.push_back(a[1]);
            int m=a[0]-a[1];
            for(int i=2;i<n;i++){
                ansx.push_back(m);
                ansy.push_back(a[i]);
                m-=a[i];
            }
            cout<<m<<endl;
            for(int i=0;i<(int)ansx.size();i++){
                printf("%d %d\n", ansx[i], ansy[i]);
            }
        }else{
            int m=mi.front(); mi.pop();
            while(pl.size()){
                int x=m;
                int y=pl.front(); pl.pop();
                if(pl.size()==0) swap(x,y);
                ansx.push_back(x);
                ansy.push_back(y);
                m=x-y;
            }
            while(mi.size()){
                int x=m;
                int y=mi.front(); mi.pop();
                ansx.push_back(x);
                ansy.push_back(y);
                m=x-y;
            }
            cout<<m<<endl;
            for(int i=0;i<(int)ansx.size();i++){
                printf("%d %d\n", ansx[i], ansy[i]);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4084