//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>
#include <iomanip>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
long long A[200005] = {};
long long B[5005][5] = {};
long long C[205][205] = {};
long long x[200005] = {};
long long y[200005] = {};
bool f, ff;
string S[2];
set <long long>sll;
pl bufpl;
vector <long long>vl[3];
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;

int main() {

	cin >> N;

	minn = 1000000000;
	maxx = -1000000000;
	d = 0;

	for (int i = 0; i < N; i++) {
		cin >> A[i];

		if (minn > A[i]) {
			minn = A[i];
		}

		if (maxx < A[i]) {
			maxx = A[i];
		}

		if (A[i] == 0) {
			vl[2].push_back(A[i]);
		}
		if (A[i] > 0) {
			vl[0].push_back(A[i]);
		}
		if (A[i] < 0) {
			vl[1].push_back(A[i]);
		}

		d += abs(A[i]);

	}

	sort(vl[0].begin(), vl[0].end());
	sort(vl[1].begin(), vl[1].end());
	reverse(vl[1].begin(), vl[1].end());
	a = 0;
	b = 0;
	c = 0;


	if (vl[2].size() == N) {
		cout << d << endl;
		for (int i = 0; i < vl[2].size() - 1; i++) {
			cout << 0 << ' ' << 0 << endl;
		}
	}
	else if (vl[2].size() == N - 1) {
		if (vl[0].size() > 0) {
			cout << d << endl;
			cout << vl[0][0] << ' ' << 0 << endl;
			for (int i = 0; i < vl[2].size() - 1; i++) {
				cout << d << ' ' << 0 << endl;
			}
		}
		else {
			cout << d << endl;
			cout << 0 << ' ' << vl[1][0] << endl;
			for (int i = 0; i < vl[2].size() - 1; i++) {
				cout << d << ' ' << 0 << endl;
			}
		}
	}
	else if (vl[0].size() == N) {
		d -= vl[0][0] * 2;

		cout << d << endl;
		x[1] = vl[0][0];
		y[1] = vl[0][1];
		for (int i = 1; i < N; i++) {

			if (i == N - 1) {
				cout << y[i] << ' ' << x[i] << endl;
			}
			else {
				cout << x[i] << ' ' << y[i] << endl;
			}

			if (i < N - 1) {
				x[i + 1] = x[i] - y[i];
				y[i + 1] = vl[0][i + 1];
			}
		}

	}
	else if (vl[1].size() == N) {
		d += vl[1][0] * 2;
		cout << d << endl;

		x[1] = vl[1][0];
		y[1] = vl[1][1];
		for (int i = 1; i < N; i++) {
			if (i == N - 1) {
				cout << x[i] << ' ' << y[i] << endl;
			}
			else {
				cout << x[i] << ' ' << y[i] << endl;
			}
			if (i < N - 1) {
				x[i + 1] = x[i] - y[i];
				y[i + 1] = vl[1][i + 1];
			}
		}

	}
	else if (N == 2) {
		cout << d << endl;
		cout << max(A[0], A[1]) << ' ' << min(A[0], A[1]) << endl;
	}
	else if (vl[0].size() == 1 && vl[1].size() == 1) {
		cout << d << endl;
		cout << vl[0][0] << ' ' << vl[1][0] << endl;
		for (int i = 0; i < vl[2].size(); i++) {
			cout << d << ' ' << 0 << endl;
		}

	}
	else if (vl[1].size() == 0) {
		cout << d << endl;
		x[0] = 0;
		y[0] = vl[0][1];
		for (int i = 0; i < vl[0].size(); i++) {

			if (i == vl[0].size() - 1) {
				cout << y[i] << ' ' << x[i] << endl;
			}
			else {
				cout << x[i] << ' ' << y[i] << endl;
			}

			if (i < vl[0].size() - 1) {
				x[i + 1] = x[i] - y[i];
				y[i + 1] = vl[0][i + 1];
			}
		}

		for (int i = 0; i < vl[2].size()-1; i++) {
			cout << d << ' ' << 0 << endl;
		}


	}
	else if (vl[0].size() == 0) {
		cout << d << endl;
		x[0] = 0;
		y[0] = vl[1][0];
		for (int i = 0; i < vl[1].size(); i++) {

			if (i == vl[1].size() - 1) {
				cout << x[i] << ' ' << y[i] << endl;
			}
			else {
				cout << x[i] << ' ' << y[i] << endl;
			}

			if (i < vl[1].size() - 1) {
				x[i + 1] = x[i] - y[i];
				y[i + 1] = vl[1][i + 1];
			}
		}

		for (int i = 0; i < vl[2].size() - 1; i++) {
			cout << d << ' ' << 0 << endl;
		}


	}
	else if (vl[0].size() > 1) {
		cout << d << endl;
		e = 0;
		x[0] = vl[1][0];
		y[0] = vl[0][0];
		for (int i = 0; i < vl[0].size(); i++) {
			if (i == vl[0].size() - 1) {
				cout << y[i] << ' ' << x[i] << endl;
			}
			else {
				cout << x[i] << ' ' << y[i] << endl;
			}

			if (i < vl[0].size() - 1) {
				x[i + 1] = x[i] - y[i];
				y[i + 1] = vl[0][i + 1];
			}
			else {
				e = y[i] - x[i];
			}
		}

		if (vl[1].size() >= 2) {
			x[1] = e;
			y[1] = vl[1][1];
			for (int i = 1; i < vl[1].size(); i++) {
				cout << x[i] << ' ' << y[i] << endl;
				if (i < vl[1].size() - 1) {
					x[i + 1] = x[i] - y[i];
					y[i + 1] = vl[1][i + 1];
				}
				else {
					e = x[i] - y[i];
				}
			}
		}

		for (int i = 0; i < vl[2].size(); i++) {
			cout << e << ' ' << 0 << endl;
		}


	}
	else {
		cout << d << endl;
		e = 0;

		if (vl[1].size() >= 2) {
			x[0] = vl[0][0];
			y[0] = vl[1][0];
			for (int i = 0; i < vl[1].size(); i++) {
				cout << x[i] << ' ' << y[i] << endl;
				if (i < vl[1].size() - 1) {
					x[i + 1] = x[i] - y[i];
					y[i + 1] = vl[1][i + 1];
				}
				else {
					e = x[i] - y[i];
				}
			}
		}


		if (vl[0].size() >= 2) {
			x[0] = vl[0][1];
			y[0] = e;
			for (int i = 0; i < vl[0].size(); i++) {
				cout << x[i] << ' ' << y[i] << endl;
				if (i < vl[0].size() - 1) {
					y[i + 1] = x[i] - y[i];
					x[i + 1] = vl[0][i + 1];
				}
				else {
					e = x[i] - y[i];
				}
			}
		}


		for (int i = 0; i < vl[2].size(); i++) {
			cout << e << ' ' << 0 << endl;
		}


	}





	return 0;

}


Measured memory_bytes: 6516