#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n;
    cin >> n;
    std::vector<int> a(n);
    std::vector<int> minus;
    std::vector<int> plus;
    std::vector<int> zero;
    std::vector<pii> out;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    std::sort(a.begin(), a.end());

    if (a[0] > 0 && a[n - 1] > 0) {
        minus.pb(a[0] - a[1]);
        out.pb({a[0], a[1]});
        for (int i = 2; i < n; i++) {
            if (a[i] < 0) {
                minus.pb(a[i]);
            } else if (a[i] > 0) {
                plus.pb(a[i]);
            } else {
                zero.pb(a[i]);
            }
        }
    } else if (a[0] < 0 && a[n - 1] < 0) {
        plus.pb(a[n - 1] - a[n - 2]);
        out.pb({a[n - 1], a[n - 2]});
        for (int i = 0; i < n - 2; i++) {
            if (a[i] < 0) {
                minus.pb(a[i]);
            } else if (a[i] > 0) {
                plus.pb(a[i]);
            } else {
                zero.pb(a[i]);
            }
        }
    } else {
        for (int i = 0; i < n; i++) {
            if (a[i] < 0) {
                minus.pb(a[i]);
            } else if (a[i] > 0) {
                plus.pb(a[i]);
            } else {
                zero.pb(a[i]);
            }
        }
    }
    std::sort(minus.begin(), minus.end(), std::greater<int>());
    std::sort(plus.begin(), plus.end());
    std::sort(zero.begin(), zero.end());


    int sum = 0;
    int ml = minus.size();
    int pl = plus.size();
    int zl = zero.size();

    for (int i = 0; i < ml; i++) {
        sum += abs(minus[i]);
    }
    for (int i = 0; i < pl; i++) {
        sum += abs(plus[i]);
    }
    std::cout << sum << endl;
    if (ml == 0 && pl == 0) {
        int zi = zero[0];
        for (int i = 1; i < zl; i++) {
            out.pb({0, 0});
        }
    } else if (ml == 0) {
        int pi = plus[0];
        if (zl > 0) {
            out.pb({zero[0], pi});
            pi = -pi;
            for (int i = 1; i < zl; i++) {
                out.pb({pi, zero[i]});
            }
        }
        for (int i = 1; i < pl - 1; i++) {
            out.pb({pi, plus[i]});
            pi = pi - plus[i];
        }
        if (pl != 0) {
            out.pb({plus[pl - 1], pi});
        }
    } else if (pl == 0) {
        int mi = minus[0];
        if (zl > 0) {
            out.pb({zero[0], mi});
            mi = -mi;
            for (int i = 1; i < zl; i++) {
                out.pb({mi, zero[i]});
            }
        }
        for (int i = 1; i < ml - 1; i++) {
            out.pb({mi, minus[i]});
            mi = mi - minus[i];
        }
        if (ml != 0) {
            out.pb({mi, minus[ml - 1]});
        }
    } else {
        int mi = minus[0];
        int pi = plus[0];
        if (zl > 0) {
            for (int i = 0; i < zl; i++) {
                out.pb({pi, zero[i]});
            }
        }
        for (int i = 1; i < ml; i++) {
            out.pb({pi, minus[i]});
            pi = pi - minus[i];
        }
        for (int i = 1; i < pl; i++) {
            out.pb({mi, plus[i]});
            mi = mi - plus[i];
        }
        out.pb({pi, mi});
    }
    for (int i = 0; i < out.size(); i++) {
        std::cout << out[i].first << " " << out[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 5872