#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int N;
LL A[100000];

int main(){
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> A[i];
	}
	sort(A, A+N);
	LL M = A[N-1] - A[0];
	for(int i=1; i<N-1; i++) M += abs(A[i]);
	cout << M << endl;
	LL small = A[0];
	LL big = A[N-1];
	for(int i=1; i<N-1; i++){
		if(A[i] < 0){
			cout << big << " " << A[i] << endl;
			big -= A[i];
		}
		else{
			cout << small << " " << A[i] << endl;
			small -= A[i];
		}
	}
	cout << big << " " << small << endl;
}
