#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;


int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

const int MOD = 1e9 + 7;



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}
/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return (x / tmp) * y;
}


/******************************************************************************************/


int main() {

	/*f () {
		cout << "Yay!" << endl;
	}
	else
	{
		cout << ":(" << endl;
	}*/
	
	int n;
	cin >> n;
	vector<int> a(n), plus, minus;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] >= 0) {
			plus.push_back(a[i]);
		}
		else
		{
			minus.push_back(a[i]);
		}
	}

	if (plus.size() == 0 || minus.size() == 0) {

		if (plus.size() == 0 && minus.size() == 0) {

			//全て0
			cout << "0" << endl;
			for (int i = 0; i < n-1; i++)
			{
				cout << "0 0" << endl;
			}
			return 0;
		}
		else if (plus.size() == 0) {

			//負数のみ
			sort(minus.begin(), minus.end(),greater<int>());


			int maxi = minus[0];
			for (int i = 1; i < minus.size(); i++)
			{
				maxi -= minus[i];
			}

			cout << maxi << endl;
			int now = 0;
			for (int i = 1; i < minus.size(); i++)
			{
				if (i == 1) {
					cout << minus[i-1] << " " << minus[i] << endl;
					now = minus[i-1] - minus[i];
				}
				else
				{
					cout << now << " " << minus[i] << endl;
					now = now - minus[i];
				}
			}

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


			sort(plus.begin(), plus.end());
			//正数のみ
			int maxi = plus[0];
			for (int i = 1; i < plus.size(); i++)
			{
				maxi -= plus[i];
			}

			cout << -maxi << endl;
			
			int now = plus[0];
			for (int i = 1; i < plus.size(); i++)
			{
				if (i == plus.size() - 1) {

					cout << plus[i] << " " << now << endl;
					now -= plus[i];

				}
				else
				{
					cout << now << " " << plus[i] << endl;
					now -= plus[i];
				}
			}
		}
	}
	else
	{
		//正負1つずつ存在

		sort(minus.begin(), minus.end(), greater<int>());

		sort(plus.begin(), plus.end());

		int mini = minus.back();
		int maxi = plus.back();

		int mini2 = mini;
		int maxi2 = maxi;
			   
		minus.pop_back();
		plus.pop_back();


		for (int i = 0; i < minus.size(); i++)
		{
			maxi -= minus[i];
		}

		for (int i = 0; i < plus.size(); i++)
		{
			mini -= plus[i];
		}

		cout << maxi - mini << endl;


		for (int i = 0; i < minus.size(); i++)
		{
			cout << maxi2 << " " << minus[i] << endl;
			maxi2 -= minus[i];
		}
		for (int i = 0; i < plus.size(); i++)
		{
			cout << mini2 << " " << plus[i] << endl;
			mini2 -= plus[i];
		}

		cout << maxi << " " << mini << endl;

	}




	return 0;
}


Measured memory_bytes: 2808