#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <limits>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}



signed main() {
    int N; cin >> N;
    vector<int> plus,minus;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        if (a >= 0) {
            plus.push_back(a);
        }
        else {
            minus.push_back(a);
        }
    }
    vector<int> lh(N-1), rh(N-1);
    sort(all(plus));
    sort(RALL(minus));
    int ans = 0;
    int buf = 0;
    if (plus.size() == 0) {
        lh[0] = minus[0];
        rh[0] = minus[1];
        rep(i, N - 2) {
            rh[i + 1] = minus[i + 2];
            lh[i + 1] = lh[i] - rh[i];            
        }
        ans = lh[N - 2] - rh[N - 2];
    }
    else if (plus.size() == 1) {
        lh[0] = plus[0];
        rh[0] = minus[0];
        rep(i, N - 2) {
            rh[i + 1] = minus[i + 1];
            lh[i + 1] = lh[i] - rh[i];
        }
        ans = lh[N - 2] - rh[N - 2];
    }
    else  if (minus.size() == 0) {
        lh[0] = plus[0];
        rh[0] = plus[1];
        rep(i, N - 3) {
            rh[i + 1] = plus[i + 2];
            lh[i + 1] = lh[i] - rh[i];
        }
        lh[N - 2] = plus[N - 2];
        rh[N - 2] = lh[N - 3] - rh[N - 3];
        ans = lh[N - 2] - rh[N - 2];
    }else if (minus.size() == 1) {
        lh[0] = minus[0];
        rh[0] = plus[0];
        rep(i, N - 3) {
            rh[i + 1] = plus[i + 1];
            lh[i + 1] = lh[i] - rh[i];
        }
        lh[N - 2] = plus[N - 2];
        rh[N - 2] = lh[N - 3] - rh[N - 3];
        ans = lh[N - 2] - rh[N - 2];
    }
    else {
        lh[0] = plus[0];
        rh[0] = minus[1];
        rep(i, minus.size() - 2) {
            lh[i + 1] = lh[i] - rh[i];
            rh[i + 1] = minus[i + 2];
        }
        int offset = minus.size()-1;
        lh[offset] = minus[0];
        rh[offset] = plus[1];
        rep(i, plus.size() - 2) {
            lh[offset+i + 1] = lh[offset + i] - rh[offset + i];
            rh[offset + i + 1] = plus[i + 2];
        }
        lh[N - 2] = lh[offset-1] - rh[offset-1];
        rh[N-2]= lh[N-3] - rh[N-3];
        ans = lh[N - 2] - rh[N - 2];
    }
    cout << ans << endl;
    rep(i, N - 1) {
        cout << lh[i] << " " << rh[i] << endl;
    }

}


Measured memory_bytes: 4340