#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>
 
#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>
 
#define cauto const auto&
#else
 
#endif
 
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;
 
#define VV(T) vector<vector< T > >
 
template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
 
template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}
 
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
 
#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)


int main() {
    int N;
    cin >> N;
    vll A(N);
    rep(i, N) cin >> A[i];

    vll plus, minus;
    vll zero;

    rep(i, N) {
        if(A[i] > 0) {
            plus.PB(A[i]);
        }        
        else if(A[i] < 0) {
            minus.PB(A[i]);
        }
        else {
            zero.PB(A[i]);
        }
    }
    if (N == 2) {
        if (A[0] > A[1]) {
            swap(A[0], A[1]);
        }
        cout << A[1] - A[0] << endl;
        cout << A[1] << " " << A[0] << endl;
        return 0;
    }

    if (zero.size() == N) {
        cout << 0 << endl;
        rep(i, N-1) cout << 0 << " " << 0 << endl;
        return 0;
    }
    if(plus.size() == 0){
        rep(i, zero.size()) plus.PB(0);
    }
    else{
        rep(i, zero.size()) minus.PB(0);
    }
    ll ans = 0;
    vector<pll> seq;
    if(plus.size() == 0) {
        sort(ALL(minus));
        reverse(ALL(minus));
        ans = minus[0];
        rep(i, N-1) {
            seq.PB(pll(ans, minus[i+1]));
            ans -= minus[i+1];
        }
    }
    else if(minus.size() == 0) {
        sort(ALL(plus));
        ans = plus[0];
        rep(i, 1, N-1) {
            seq.PB(pll(ans, plus[i]));
            ans -= plus[i];
        }
        seq.PB(pll(plus[N-1], ans));
        ans = plus[N-1] - ans;
    }
    else {
        sort(ALL(plus));
        sort(ALL(minus));
        reverse(ALL(minus));
        ans = minus[0];
        rep(i, plus.size()-1) {
            seq.PB(pll(ans, plus[i]));
            ans -= plus[i];
        }
        seq.PB(pll(plus.back(), ans));
        ans = plus.back() - ans;
        rep(i, 1, minus.size()) {
            seq.PB(pll(ans, minus[i]));
            ans -= minus[i];
        }
    }
    cout << ans << endl;
    assert(seq.size() == N-1);
    rep(i, seq.size()) {
        cout << seq[i].fi << " " << seq[i].se << endl;
    }
}


/*

1 2 3 4

1 - 2

-1 - 3

4 - -4

-1 -2 -3

-1 - -2
1   4

-1 - -3
2   4

-2

-a

4 - -a

a

a - - 4

a b c

-1

-1 - a

*/

Measured memory_bytes: 6256