//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define  N  (200'005)
#define MOD (1'000'000'007ll)
#define OO (1'050'000'000)
#define OOL (1'100'000'000'000'000'000ll)

//global
ll a[N];

ll mi(ll l,ll r);
 
ll ma(ll l,ll r){
	if(l == r) return a[l];
	ll val = mi(l,r-1);
	cout << a[r] << " " << val << endl;
	return a[r]-val;
}
 
ll mi(ll l,ll r){
	if(l == r) return a[l];
	ll val = ma(l+1,r);
	cout << a[l] << " " << val << endl;
	return a[l]-val;
}

int main(){
	//fold
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	//endfold
	int n;
	cin >> n;
	ll ans = 0;
	multiset<ll> neg;
	multiset<ll> pos;
	rep(i,0,n){
		cin >> a[i];
		if(a[i] < 0) neg.insert(a[i]);
		else pos.insert(a[i]);
	}
	vector<pair<ll,ll>> v;
	if(sz(pos) > sz(neg)){
		ll cur;
		ll diff = sz(pos)-sz(neg)-2*(sz(neg) == 0);
		if(sz(neg) == 0){
			cur = *pos.begin();
			pos.erase(pos.begin());
		}else{
			cur = *neg.rbegin();
			neg.erase(neg.find(cur));
		}
		rep(i,0,diff){
			v.push_back({cur,*pos.begin()});
			cur = cur - *pos.begin();
			pos.erase(pos.begin());
		}
		neg.insert(cur);
	}
	if(sz(neg) > sz(pos)){
		ll cur;
		ll diff = sz(neg)-sz(pos)-2*(sz(pos) == 0);
		if(sz(pos) == 0){
			cur = *neg.rbegin();
			neg.erase(neg.find(cur));
		}else{
			cur = *pos.begin();
			pos.erase(pos.begin());
		}
		rep(i,0,diff){
			v.push_back({cur,*neg.rbegin()});
			cur = cur - *neg.rbegin();
			neg.erase(neg.find(*neg.rbegin()));
		}
		pos.insert(cur);
	}
	n = sz(pos)+sz(neg);
	int id = 0;
	for(int we:neg){
		a[id] = we;
		id++;
	}
	for(int we:pos){
		a[id] = we;
		id++;
	}
	sort(a,a+n);
	rep(i,0,n){
		if(i <= (n)/2-1) ans += -a[i];
		else ans += a[i];
	}
	cout << ans << endl;
	rep(i,0,sz(v)){
		cout << v[i].first << " " << v[i].second << endl;
	}
	ll val = mi(0,n-2);
	cout << a[n-1] << " " << val << endl;
	return 0;
}

Measured memory_bytes: 11904