Problem:
Score : 500 points

Problem Statement

There are N integers, A_1, A_2, ..., A_N, written on a blackboard.

We will repeat the following operation N-1 times so that we have only one integer on the blackboard.

Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.

Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.

Constraints

2 \leq N \leq 10^5

-10^4 \leq A_i \leq 10^4

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print the maximum possible value M of the final integer on the blackboard, and a sequence of operations x_i, y_i that maximizes the final integer, in the format below.

Here x_i and y_i represent the integers x and y chosen in the i-th operation, respectively.

If there are multiple sequences of operations that maximize the final integer, any of them will be accepted.

M
x_1 y_1
:
x_{N-1} y_{N-1}

Sample Input 1

3
1 -1 2

Sample Output 1

4
-1 1
2 -2

If we choose x = -1 and y = 1 in the first operation, the set of integers written on the blackboard becomes (-2, 2).

Then, if we choose x = 2 and y = -2 in the second operation, the set of integers written on the blackboard becomes (4).

In this case, we have 4 as the final integer. We cannot end with a greater integer, so the answer is 4.

Sample Input 2

3
1 1 1

Sample Output 2

1
1 1
1 0

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>


#define ll long long
#define pii pair<int,int >
#define pll pair<long long ,long long >
#define pbb pair<bool,bool>
#define plll pair<long long,pair<long long ,long long > > 
#define sefi second.first
#define sese second.second
#define fi first
#define se second
#define ld long double
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz(x) x.size()
#define cont continue
//#define int long long 

const long long  md = 1e9 + 9;
const int Inf = 1e9;
const ll Inf64 = 1e18;
const ll MaxN = 1e5 + 10;
const ll MaxM = 11;
const ld eps = 1e-15;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { 1,0,-1,0 };
const ll ddx[4] = { 1,1,-1,-1 };
const ll ddy[4] = { 1,-1,1,-1 };

using namespace std;

ll gcd(ll a, ll b) {
	while (a) {
		b %= a;
		swap(a, b);
	}
	return b;
}
ll gcdex(ll a, ll mod = md) {
	ll g = mod, r = a, x = 0, y = 1;
	while (r != 0) {
		ll q = g / r;
		g %= r;
		swap(g, r);
		x -= q * y;
		swap(x, y);
	}
	return x < 0 ? x + mod : x;
}

ll binpow(ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1) {
			res *= a;
			res %= md;
		}
		a *= a;
		a %= md;
		n >>= 1;
	}
	return res % md;
}
// /
/// ////
// ///////



signed main() {
	ios_base::sync_with_stdio(0);
	//ifstream cin("penalty.in");
	//ofstream cout("penalty.out");
	cin.tie(0);
	cout.tie(0);
	cerr.tie(0);
	// //
	//cout << fixed,cout.precision(10);
	// //

	
	ll N;
	cin >> N;
	if (N == 1) {
		ll a;
		cin >> a;
		cout << a;
		return 0;
	}
	else {
		vector<ll > Mt(N);
		ll Sum = 0;
		ll t = Inf;
		ll r = -Inf;
		for (int i = 0;i < N;i++) {
			cin >> Mt[i];
			Sum += abs(Mt[i]);
			t = min(Mt[i], t);
			r = max(Mt[i], r);

		}
		//sort(all(Mt));
		ll Mn = Inf;
		ll id = 0;
		for (int i = 0;i < N;i++) {
			Mn = min(Mn, abs(Mt[i]));
			if (Mn == abs(Mt[i]))
				id = i;
		}
		if (t * r < 0) {
			cout << Sum << '\n';
			
		}
		else {
			
			cout << Sum - 2 * Mn << '\n';
		}
		ll k = Mt[id];
		if (id == N - 1) {
			for (int i = id - 1;i > 0;i--) {
				cout << min(Mt[i], k) << ' ' << max(Mt[i], k) << '\n';
				k = min(Mt[i], k) - max(Mt[i], k);
			}
			cout << max(Mt[0], k) << ' ' << min(Mt[0], k) << '\n';
			return 0;
		}
		for (int i = id - 1;i > -1;i--) {
			cout << min(Mt[i],k) << ' ' << max(Mt[i], k) << '\n';
			k = min(Mt[i], k) - max(Mt[i], k);
		}
		for (int i = id + 1;i < N-1;i++) {
			cout << min(Mt[i], k) << ' ' << max(Mt[i], k) << '\n';
			k = min(Mt[i], k) - max(Mt[i], k);
		}
		cout << Mt.back() << ' ' << k;

	}

	/// ///////////////
	cerr << '\n' << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << '\n';

	return 0;

}
/*


*/