#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}
};
ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}
typedef vector<vector<Edge>> Graph;
//BEGIN CUT HEREd
struct RUP {
	int n;
	vector<int> dat, laz;
	const int def = INT_MAX;
	RUP() {}
	RUP(int n_) { init(n_); }
	void init(int n_) {
		n = 1;
		while (n < n_) n *= 2;
		dat.clear();
		dat.resize(2 * n - 1, def);
		laz.clear();
		laz.resize(2 * n - 1, -1);
	}
	inline void eval(int len, int k) {
		if (laz[k] < 0) return;
		if (k * 2 + 1 < n * 2 - 1) {
			laz[k * 2 + 1] = laz[k];
			laz[k * 2 + 2] = laz[k];
		}
		dat[k] = laz[k];
		laz[k] = -1;
	}
	int update(int a, int b, int x, int k, int l, int r) {
		eval(r - l, k);
		if (r <= a || b <= l) return dat[k];
		if (a <= l && r <= b) return laz[k] = x;
		eval(r - l, k);
		dat[k] = min(update(a, b, x, k * 2 + 1, l, (l + r) / 2),
			update(a, b, x, k * 2 + 2, (l + r) / 2, r));
		return dat[k];
	}
	int query(int a, int b, int k, int l, int r) {
		eval(r - l, k);
		if (r <= a || b <= l) return def;
		if (a <= l && r <= b) return dat[k];
		int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
	void update(int a, int b, int x) {
		update(a, b, x, 0, 0, n);
	}
	int query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};
//END CUT HERE

int mdt(Graph& g, vector<int>& d, int st) {

	queue<pii> pos;

	d.resize(g.size(), -1);
	pii ans = { -1,-1 };

	pos.push({ 0,st });

	while (pos.size()) {
		pii cur = pos.front();
		pos.pop();

		if (d[cur.second] != -1)
			continue;

d[cur.second] = cur.first;
chmax(ans, cur);

for (auto itr : g[cur.second]) {
	pos.push({ cur.first + 1, itr.to });
}

	}

	return ans.second;
}


pair<pii, int> md(Graph& g, int stp = 0) {
	vector<int> d;
	int st = mdt(g, d, stp);
	d = vector<int>();
	int en = mdt(g, d, st);
	int mid = -1;

	if (d[en] % 2 == 0) {
		int cur = en;
		while (d[cur] != d[en] / 2) {
			for (auto itr : g[cur]) {
				if (d[itr.to] == d[cur] - 1) {
					cur = itr.to;
					break;
				}
			}
		}
		mid = cur;
	}

	return { { st,en },mid };
}


bool check(Graph& g, int root) {
	queue<pii> pos;

	vector<int> d(g.size(), -1), deg(g.size(), -1);
	pos.push({ 0,root });
	while (pos.size()) {
		pii cur = pos.front();
		pos.pop();

		if (d[cur.second] != -1)
			continue;

		d[cur.second] = cur.first;

		if (deg[cur.first] == -1) deg[cur.first] = g[cur.second].size();

		if (deg[cur.first] != g[cur.second].size())
			return false;

		for (auto itr : g[cur.second]) {
			pos.push({ cur.first + 1, itr.to });
		}

	}

	return true;
}

signed main(void) {
	int n;
	cin >> n;
	vector<int> a(n), p, m;

	REP(i, n) {
		cin >> a[i];
		if (a[i] > 0)
			p.push_back(a[i]);
		else
			m.push_back(a[i]);
	}

	sort(ALL(p), greater<int>());
	sort(ALL(m));

	vector<pii> ans;

	vector<int> mar;


	if (m.size() == 0) {
		m.push_back(p.back());
		p.pop_back();
	}
	if (p.size() == 0) {
		p.push_back(m.back());
		m.pop_back();
	}

	int bb = m[0];
	rep(i, 1, p.size()) {
		ans.push_back(MP(bb, p[i]));
		bb -= p[i];
	}
	mar.push_back(bb);

	rep(i, 1, m.size()){
		mar.push_back(m[i]);
	}

	int base = p[0];
	REP(i, mar.size()) {
		ans.push_back(MP(base, mar[i]));
		base = base - mar[i];
	}

	cout << base << endl;

	for (auto itr : ans) {
		cout << itr.first << " " << itr.second << endl;
	}

	return 0;
}


Measured memory_bytes: 3956