#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> po;
    std::vector<int> ne;
    std::vector<int> ze;
    int pos = 0;
    int neg = 0;
    int zero = 0;
    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        if (temp > 0) {
            pos = 1;
            po.pb(temp);
        } else if (temp == 0) {
            zero = 1;
            ze.pb(temp);
        } else {
            neg = 1;
            ne.pb(temp);
        }
    }


    std::vector<pii> out;
    int sum = 0;
    if (zero == 1) {
        sum = ze[0];
        for (int i = 1; i < ze.size(); i++) {
            out.pb({sum, ze[i]});
            sum += ze[i];
        }
        if (pos == 0) {
            for (int i = 0; i < ne.size(); i++) {
                out.pb({sum, ne[i]});
                sum -= ne[i];
            }
        } else {
            for (int i = 1; i < po.size(); i++) {
                out.pb({sum, po[i]});
                sum -= po[i];
            }
            out.pb({po[0], sum});
            sum = po[0] - sum;
            for (int i = 0; i < ne.size(); i++) {
                out.pb({sum, ne[i]});
                sum -= ne[i];
            }
        }
    } else if (pos == 0) {
        std::sort(ne.begin(), ne.end(), std::greater<int>());
        out.pb({ne[0], ne[1]});
        sum = ne[0] - ne[1];
        for (int i = 2; i < ne.size(); i++) {
            out.pb({sum, ne[i]});
            sum -= ne[i];
        }
    } else if (neg == 0) {
        std::sort(po.begin(), po.end());
        if (po.size() == 2) {
            out.pb({po[1], po[0]});
            sum = po[1] - po[0];
        } else {
            out.pb({po[0], po[1]});
            sum = po[0] - po[1];
            for (int i = 2; i < po.size() - 1; i++) {
                out.pb({sum, po[i]});
                sum -= po[i];
            }
            out.pb({po[po.size() - 1], sum});
            sum = po[po.size() - 1] - sum;
        }
    } else {
        if (po.size() == 1) {
            out.pb({po[0], ne[0]});
            sum = po[0] - ne[0];
            for (int i = 1; i < ne.size(); i++) {
                out.pb({sum, ne[i]});
                sum -= ne[i];
            }
        } else {
            out.pb({ne[0], po[0]});
            sum = ne[0] - po[0];
            for (int i = 2; i < po.size(); i++) {
                out.pb({sum, po[i]});
                sum -= po[i];
            }
            out.pb({po[1], sum});
            sum = po[1] - sum;
            for (int i = 1; i < ne.size(); i++) {
                out.pb({sum, ne[i]});
                sum -= ne[i];
            }
        }
    }
    cout << sum << endl;

    for (int i = 0; i < out.size(); i++) {
        cout << out[i].first << " " << out[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 5232