#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second

int main()
{

	ll n;
	cin>>n;

	vector<ll> po;
	vector<ll> ne;
	vector<ll> zero;


	for(ll i = 0 ; i < n ; i++)
	{

		ll t1;
		cin>>t1;

		if(t1 > 0)
		{
			po.pb(t1);
		}
		else if(t1 < 0)
		{
			ne.pb(t1);
		}
		else if(t1 == 0)
		{
			zero.pb(t1);
		}
	}

	if(zero.size() == n)
	{
		cout<<0<<endl;

		for(ll i = 0 ; i < n - 1 ; i++)
		{
			cout<<0<<" "<<0<<endl;
		}

	}
	else if(ne.size() == 0 && zero.size() == 0)
	{
		sort(po.begin(),po.end());

		ll sum = 0;

		for(ll i = 1 ; i < po.size(); i++)
		{
			sum += po[i];
		}

		sum -= po[0];

		cout<<sum<<endl;

		sum = 0;

		if(po.size() == 2)
		{
			cout<<po[po.size() - 1]<<" "<<po[po.size() - 2]<<endl;
			sum = po[po.size() - 1] - po[po.size() - 2];

			for(ll i = 0 ; i < zero.size() ; i++)
			{
				cout<<sum<<" "<<zero[i]<<endl;
			}

			return 0;

		}

		for(ll i = 0 ; i < po.size() - 1 ; i++)
		{
			if(i == 0)
			{
				cout<<po[i]<<" "<<po[i+1]<<endl;
				sum = po[i] - po[i+1];
				i++; 
			}
			else
			{
				cout<<sum<<" "<<po[i]<<endl;
				sum -= po[i];
			}

		}

		if(po.size() != 2)
		{
			cout<<po[po.size() - 1]<<" "<<sum<<endl;
			sum = po[po.size() - 1] - sum;
		}
	


		for(ll i = 0 ; i < zero.size() ; i++)
		{
			cout<<sum<<" "<<zero[i]<<endl;
		}

	}
	else if(po.size() == 0 && zero.size() == 0)
	{
		sort(ne.begin(),ne.end());

		reverse(ne.begin(),ne.end());

		ll sum = 0;

		for(ll i = 1 ; i < ne.size() ; i++)
		{
			sum += abs(ne[i]);
		}

		sum += ne[0];

		cout<<sum<<endl;

		sum = 0;

		for(ll i = 0 ; i < ne.size() ; i++)
		{
			if(i == 0)
			{
				cout<<ne[i]<<" "<<ne[i+1]<<endl;
				sum = ne[i] - ne[i+1];
				i++;
			}
			else
			{
				cout<<sum<<" "<<ne[i]<<endl;
				sum -= ne[i];
			}
		}

		for(ll i = 0 ; i < zero.size() ; i++)
		{
			cout<<sum<<" "<<zero[i]<<endl;
		}

	}
	else if(po.size() == 0)
	{
		ll sum = 0;

		ll cnt = 0;

		for(ll i = 0 ; i < ne.size() ; i++)
		{
			cnt += abs(ne[i]);
		}

		cout<<cnt<<endl;

		for(ll i = 0 ; i < zero.size() - 1 ; i++)
		{
			cout<<0<<" "<<0<<endl;
		} 

		for(ll i = 0 ; i < ne.size() ; i++)
		{
			cout<<sum<<" "<<ne[i]<<endl;
			sum -= ne[i];
		}

	}
	else if(ne.size() == 0)
	{

		ll cnt = 0;

		for(ll i = 0 ; i < po.size() ; i++)
		{
			cnt += abs(po[i]);
		}

		cout<<cnt<<endl;

		ll sum = 0;

		for(ll i = 0 ; i < zero.size() - 1 ; i++)
		{
			cout<<0<<" "<<0<<endl;
		}

		for(ll i = 0 ; i < po.size() - 1; i++)
		{
			cout<<sum<<" "<<po[i]<<endl;
			sum -= po[i];
		}

		cout<<po[po.size() - 1]<<" "<<sum<<endl;


	}
	else
	{
		sort(po.begin(),po.end());
		sort(ne.begin(),ne.end());

		ll cnt = 0;

		for(ll i = 0 ; i < po.size() ; i++)
		{
			cnt += po[i];
		}

		for(ll i = 0 ; i < ne.size() ; i++)
		{
			cnt += abs(ne[i]);
		}

		cout<<cnt<<endl;

		ll sum = 0;

		for(ll i = 0 ; i < po.size() - 1; i++)
		{
			if(i == 0)
			{
				cout<<ne[0]<<" "<<po[i]<<endl;
				sum = ne[0] - po[i];
			}
			else
			{
				cout<<sum<<" "<<po[i]<<endl;
				sum -= po[i];
			}
		}

		// cout<<"sum "<<sum<<endl;

		if(po.size() != 1)
		{
			for(ll i = 0 ; i < ne.size() ; i++)
			{
				if(i == 0)
				{
					cout<<po[po.size() - 1]<<" "<<sum<<endl;
					sum = po[po.size() - 1] - sum;					
				}
				else
				{
					cout<<sum<<" "<<ne[i]<<endl;
					sum -= ne[i];
				}
			}
		}
		else if(po.size() == 1)
		{
			for(ll i = 0 ; i < ne.size() ; i++)
			{
				if(i == 0)
				{
					cout<<po[i]<<" "<<ne[i]<<endl;
					sum = po[i] - ne[i];
				}
				else
				{
					cout<<sum<<" "<<ne[i]<<endl;
					sum = sum - ne[i];
				}
			}
		}

		for(ll i = 0 ; i < zero.size() ; i++)
		{
			cout<<sum<<" "<<zero[i]<<endl;
		}

	}
}



Measured memory_bytes: 2804