#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}
ll dive10(ll b, ll s, ll n, ll m)
{
	b = div2mul_calc(b, n, m);
	ll i = 1;
	ll c = b;
	ll r = 1;
	ll t = b;
	ll k = 1;
	while(i)
	{
		if(i&s)
		{
			r += c*k;
			r %= m;
			k *= t;
			k %= m;
		}
		c = c + c*t;
		c %= m;
		t = t*t;
		t %= m;
		i <<= 1;
	}
	return r;
}
ll divet10(ll b, ll s, ll n, ll m)
{
	b = div2mul_calc(b, n, m);
	ll i = 1;
	ll c = b;
	ll r = 1;
	ll t = b;
	ll k = 1;
	while(i)
	{
		if(i&s)
		{
			r += c*k;
			r %= m;
			k *= t;
			k %= m;
		}
		c = c + c*t;
		c %= m;
		t = t*t;
		t %= m;
		i <<= 1;
	}
	return r;
}
int main()
{
	int N;
	int A[100010] = {0};
	vector<int> plus;
	vector<int> minas;
	cin >> N;
	int i,j,k;
	int min_index = -1;
	int min_num = 1000000;
	int total = 0;
	int min_plus = 10000000;
	int min_plus_index = -1;
	int max_minas = -10000000;
	int max_minas_index = -1;
	for(i=0; i<N; ++i)
	{
		cin >> A[i];
		if(A[i] >= 0)
		{
			plus.push_back(i);
			if(min_plus > A[i])
			{
				min_plus = A[i];
				min_plus_index = plus.size()-1;
			}
		}
		else
		{
			minas.push_back(i);
			if(max_minas < A[i])
			{
				max_minas = A[i];
				max_minas_index = minas.size()-1;
			}
		}
	}
	if(plus.size()==0)
	{
		plus.push_back(minas[max_minas_index]);
		minas.erase(minas.begin()+max_minas_index);
	}
	if(minas.size()==0)
	{

		minas.push_back(plus[min_plus_index]);
		plus.erase(plus.begin()+min_plus_index);
	}
	int plus_len = plus.size();
	int minas_len = minas.size();

	int cur_point = 0;

	for(i=0;i<plus_len;++i)
	{
		cur_point += A[plus[i]];
	}

	for(i=0;i<minas_len;++i)
	{
		cur_point -= A[minas[i]];
	}
	cout << cur_point << endl;
	cur_point = 0;
	if(plus_len > 1)
	{
		cur_point = A[minas[0]] - A[plus[0]];
		cout << A[minas[0]] << " " << A[plus[0]] << endl;
		for(i = 1;i<plus_len-1;++i)
		{
			cout << cur_point << " " <<  A[plus[i]] << endl;
			cur_point -= A[plus[i]];
		}
		cout << A[plus[plus_len-1]] << " " << cur_point << endl;
		cur_point = A[plus[plus_len-1]] - cur_point;
		for(i=1; i<minas_len;++i)
		{
			cout << cur_point << " " << A[minas[i]] << endl;
			cur_point -= A[minas[i]];
		}
	}
	else
	{
		cur_point = A[plus[0]];
		for(i=0; i<minas_len;++i)
		{
			cout << cur_point << " " << A[minas[i]] << endl;
			cur_point -= A[minas[i]];
		}
	}

	return 0;
}




































Measured memory_bytes: 2808