#include<bits/stdc++.h>
using namespace std;
int in[100005];
int main() {
    int n; scanf("%d",&n);
    int zh1=0,fu1=0;
    int Min=0x3f3f3f3f,Max=0x80000000,sum=0;
    for(int i=0;i<n;i++) {
        scanf("%d",in+i);
        if(in[i]>=0) {
            zh1++;
        }
        if(in[i]<0) {
            fu1++;
        }
        Min=min(Min,in[i]);
        Max=max(Max,in[i]);
        sum+=abs(in[i]);
    }
    if(zh1&&fu1) {
        printf("%d\n",sum);
    }
    else {
        if(zh1) {
            printf("%d\n",sum-2*Min);
        }
        else {
            printf("%d\n",sum+2*Max);
        }
    }
    if(n==2) {
        printf("%d %d\n",Max,Min);
        return 0;
    }
    if(zh1&&fu1) {
        int fisfu,a,fiszh,b;
        for(int i=0;i<n;i++) {
            if(in[i]>=0){
                fiszh=i;
                a=in[i];
                break;
            }
        }
        for(int i=0;i<n;i++) {
            if(in[i]<0){
                fisfu=i;
                b=in[i];
                break;
            }
        }
        for(int i=0;i<n;i++) {
            if(i==fisfu||i==fiszh) continue;
            if(in[i]>=0) {
                printf("%d %d\n",b,in[i]);
                b-=in[i];
            }
            else {
                printf("%d %d\n",a,in[i]);
                a-=in[i];
            }
        }
        printf("%d %d\n",a,b);
    }
    else {
        Min=0x3f3f3f3f,Max=0x80000000;
        if(zh1) {
            int Minnum;
            for(int i=0;i<n;i++) {
                if(in[i]<Min) {
                    Min=in[i];
                    Minnum=i;
                }
            }
            int choose,choose2;
            if(Minnum==0) choose=1;
            else if(Minnum==n-1) choose=1;
            else choose=Minnum+1;
            int fu=Min-in[choose];
            printf("%d %d\n",Min,in[choose]);
            int zh;
            for(int i=0;i<n;i++) {
                if(i!=Minnum&&i!=choose) {
                    choose2=i;//cout<<Minnum<<choose<<choose2<<endl;
                    zh=in[i];break;
                }
            }

            for(int i=0;i<n;i++) {
                if(i==Minnum||i==choose||i==choose2) continue;
                printf("%d %d\n",fu,in[i]);
                fu-=in[i];
            }
            printf("%d %d\n",zh,fu);
        }
        else {
            int Maxnum;
            for(int i=0;i<n;i++) {
                if(in[i]>Max) {
                    Max=in[i];
                    Maxnum=i;
                }
            }
            int choose,choose2;
            if(Maxnum==0) choose=1;
            else if(Maxnum==n-1) choose=1;
            else choose=Maxnum+1;
            int zh=Max-in[choose];
            printf("%d %d\n",Max,in[choose]);
            int fu;
            for(int i=0;i<n;i++) {
                if(i!=Maxnum&&i!=choose) {
                    choose2=i;
                    fu=in[i];break;
                }
            }
            for(int i=0;i<n;i++) {
                if(i==Maxnum||i==choose||i==choose2) continue;
                printf("%d %d\n",zh,in[i]);
                zh-=in[i];
            }
            printf("%d %d\n",zh,fu);
        }
    }
}


Measured memory_bytes: 2304