#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

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

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    VL a(n);
    REP(i,n)cin>>a[i];
    SORT(a);
    bool all_neg = a[n-1] <= 0;
    bool all_pog = a[0] > 0;
    if(all_neg){
        LL sum = 0;
        REP(i,n-1){
            sum += -a[i];
        }
        sum += a[n-1];

        PUTS(sum);
        LL x = a[n-1];
        REP(i,n-1){
            LL y = a[i];
            cout<< x <<" "<< y <<endl;
            x = x - y;
        }
    }
    else if(!all_pog){
        LL sum = 0;
        REP(i,n-1){
            sum += abs(a[i]);
        }
        sum += a[n-1];

        PUTS(sum);
        LL x = a[n-1];
        int i = 0;
        for(i = n - 2; i>=1 && a[i] >= 0; i--){
            LL x = a[0];
            LL y = a[i];
            cout<< x <<" "<< y <<endl;
            a[0] = x - y;
        }
        for(;i>=0;i--){
            LL x = a[n-1];
            LL y = a[i];
            cout<< x <<" "<< y <<endl;
            a[n-1] = x - y;
        }
    }
    else if(n == 2){
        PUTS(a[1] - a[0]);
        cout<< a[1] <<" "<< a[0] <<endl;
    }
    else{
        LL z = a[0] - a[n-1];
        if(z == 0 && n == 3){
            PUTS(a[0]);
            cout<< a[0] <<" "<< a[1] <<endl;
            cout<< a[2] <<" "<< 0 <<endl;
        }
        else{
            VL b = a;
            a[0] = a[0] - a[n-1];
            for(int i = 1; i < n - 2; i++){
                LL x = a[0];
                LL y = a[i];
                a[0] = x - y;
            }

            PUTS(a[n-2] - a[0]);
            a = b;
            cout<< a[0] <<" "<< a[n-1] <<endl;
            a[0] = a[0] - a[n-1];
            for(int i = 1; i < n - 2; i++){
                LL x = a[0];
                LL y = a[i];
                cout<< x <<" "<< y <<endl;
                a[0] = x - y;
            }
            cout<< a[n-2] <<" "<< a[0] <<endl;
        }
    }
}

Measured memory_bytes: 3328