#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

typedef struct {
	int I;
	int from;
	int cost;
	vector<pair<int,int>> to;
} _node;

bool operator > (const _node& a,const _node& b) {
	return a.cost > b.cost;
}
class Dijkstra {
public:
	int start,fin;
	vector<_node> node;
	vector<int> path;
	priority_queue<_node,vector<_node>,greater<_node>> pque;
	void ds_init(int n) {
		node = vector<_node>(n);
		for (int i = 0;i < n;i++) {
			node[i].I = i;
			node[i].from = i;
			node[i].cost = INF;
		}
	}
	void dijkstra(int s,int ficost = 0) {
		node[s].cost = ficost;
		for (int i = 0;i < node[s].to.size();i++) {
			node[node[s].to[i].first].cost = node[s].to[i].second + node[s].cost;
			node[node[s].to[i].first].from = s;
			pque.push(node[node[s].to[i].first]);
		}
		while (!pque.empty()) {
			_node next = pque.top();
			pque.pop();
			if (next.cost > node[next.I].cost) continue;
			for (int i = 0;i < next.to.size();i++) {
				if (node[next.to[i].first].cost > next.cost + next.to[i].second) {
					node[next.to[i].first].cost = next.cost + next.to[i].second;
					node[next.to[i].first].from = next.I;
					pque.push(node[next.to[i].first]);
				}
			}
		}
	}
	void searchpath(int now) {
		if (node[now].from != now) {
			path.push_back(node[now].from);
			searchpath(node[now].from);
		} else {
			reverse(ALL(path));
			return;
		}
	}
};

bool cmp(int &a, int &b) {
	return abs(a) < abs(b);
}

bool solve() {
	int n; cin>>n; vector<int> B,C;
	vector<int> A(n); REP (i,n) {
		int x; cin >> x;
		if (x > 0) B.pb(x);
		else C.pb(x);
	}
	sort(ALL(B)), sort(ALL(C));
	reverse(ALL(C));
	if (C.size() == 0) {
		A = B;
	} else if (B.size() == 0) {
		A = C;
	} else {
		A[0]=B[0];
		A[1]=C[0];
		int pos = 2;
		FOR (i,1,B.size()) {
			A[pos] = B[i];
			pos++;
		}
		FOR (i,1,C.size()) {
			A[pos] = C[i];
			pos++;
		}
	}
	int tmp = abs(A[0]-A[1]);
	FOR (i,2,n) {
		tmp = max({tmp-A[i],-tmp-A[i],A[i]-tmp,A[i]+tmp});
	}
	int sm,bg; sm = min(A[0],A[1]), bg = max(A[0],A[1]);
	// cout << tmp << endl;
	pair<int,int> ans[n-1];
	FOR (i,2,n) {
		if (A[i] > 0) {
			ans[i-2].F = sm,ans[i-2].S=bg;
			sm = min(sm-bg,A[i]), bg = max(sm-bg,A[i]);
		} else {
			ans[i-2].F = bg,ans[i-2].S=sm;
			bg = max(bg-sm,A[i]), sm = min(bg-sm,A[i]);
		}
	}
	ans[n-2]={bg,sm};
	cout << ans[n-2].F-ans[n-2].S << endl;
	REP (i,n-1) {
		cout << ans[i].F << " " << ans[i].S << endl;
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 5236