#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n=0,nn,i,j,sum=0,keep,m=0,p=0,z,flag=0;
	long long a[100005],b;
	cin >> nn;
	for(i=0;i<nn;i++){
		cin >> keep;
		if(keep!=0){
			a[n]=keep;
			n++;
		}
		sum+=abs(keep);
	}
	for(i=1;i<n;i++){
		if(a[i]!=a[i-1]) flag=1;
	}
	z=nn-n;
	if(n==0){
		cout << "0" << endl;
		for(i=1;i<z;i++) cout << "0 0" << endl;
		return 0;
	}
	sort(a,a+n);
	for(i=0;i<n;i++){
		if(a[i]<0) m++;
		else p++;
	}
	if(z==0&&flag==0){
		if(p!=0){
			cout << a[0]*(n-2) << endl;
			cout << a[0] << " " << a[0] << endl;
			for(i=1;i<n-2;i++){
				cout << -a[0]*(i-1) << " " << a[0] << endl;
			}
			if(n>2) cout << a[0] << " " << -a[0]*(n-3) << endl;
			for(i=1;i<=z;i++) cout << keep << " 0" << endl;
		} else {
			cout << -a[0]*(n-2) << endl;
			cout << a[0] << " " << a[0] << endl;
			for(i=1;i<n-1;i++){
				cout << -a[0]*(i-1) << " " << a[0] << endl;
			}
			for(i=1;i<=z;i++) cout << keep << " 0" << endl;
		}
		return 0;
	}
	if(z!=0&&flag==0){
		if(p!=0){
			cout << a[0]*n << endl;
			cout << "0 " << a[0] << endl;
			for(i=1;i<n-1;i++){
				cout << -a[0]*i << " " << a[0] << endl;
			}
			cout << a[0] << " " << -a[0]*(n-1) << endl;
			for(i=1;i<z;i++) cout << keep << " 0" << endl;
		} else {
			cout << -a[0]*n << endl;
			cout << "0 " << a[0] << endl;
			for(i=1;i<n;i++){
				cout << -a[0]*i << " " << a[0] << endl;
			}
			for(i=1;i<z;i++) cout << keep << " 0" << endl;
		}
		return 0;
	}
	if(m!=0&&p!=0){
		cout << sum << endl;
		keep=a[m-1];
		for(i=m;i<n;i++){
			if(i==n-1){
				cout << a[i] << " " << keep << endl;
				keep=a[i]-keep;
			} else {
				cout << keep << " " << a[i] << endl;
				keep=keep-a[i];
			}
		}
		for(i=0;i<m-1;i++){
			cout << keep << " " << a[i] << endl;
			keep=keep-a[i];
		}
		for(i=1;i<=z;i++) cout << keep << " 0" << endl;
		return 0;
	}
	if(z!=0){
		if(m==0){
			cout << sum << endl;
			cout << "0 " << a[0] << endl;
			keep=-a[0];
			for(i=1;i<n-1;i++){
				cout << keep << " " << a[i] << endl;
				keep=keep-a[i];
			}
			cout << a[n-1] << " " << keep << endl;
			for(i=1;i<z;i++) cout << sum << " 0" << endl;
		} else {
			cout << sum << endl;
			cout << "0 " << a[0] << endl;
			keep=-a[0];
			for(i=1;i<n;i++){
				cout << keep << " " << a[i] << endl;
				keep=keep-a[i];
			}
			for(i=1;i<z;i++) cout << sum << " 0" << endl;
		}
		return 0;
	}
	if(m==0) {
		cout << sum - 2*a[0] << endl;
		for(i=1;i<n;i++){
			if(a[i]!=a[0]){
				cout << a[0] << " " << a[i] << endl;
				a[0]=a[0]-a[i];
				a[i]=10000000;
				break;
			}
		}
			sort(a,a+n);
			n=n-1;
			p=p-2;
			m=1;
			if(m!=0&&p!=0){
				keep=a[m-1];
				for(i=m;i<n;i++){
					if(i==n-1){
						cout << a[i] << " " << keep << endl;
						keep=a[i]-keep;
					} else {
						cout << keep << " " << a[i] << endl;
						keep=keep-a[i];
					}
				}
				for(i=1;i<m;i++){
					cout << keep << " " << a[i] << endl;
					keep=keep-a[i];
				}
			}
		for(i=1;i<=z;i++) cout << keep << " 0" << endl;
	} else {
		cout << sum + 2*a[n-1] << endl;
		for(i=0;i<n-1;i++){
			if(a[i]!=a[n-1]){
				cout << a[n-1] << " " << a[i] << endl;
				a[n-1]=a[n-1]-a[i];
				a[i]=10000000;
				break;
			}
		}
			sort(a,a+n);
			n=n-1;
			m=m-2;
			p=1;
			if(m!=0&&p!=0){
				keep=a[m-1];
				for(i=m;i<n;i++){
					if(i==n-1){
						cout << a[i] << " " << keep << endl;
						keep=a[i]-keep;
					} else {
						cout << keep << " " << a[i] << endl;
						keep=keep-a[i];
					}
				}
				for(i=0;i<m-1;i++){
					cout << keep << " " << a[i] << endl;
					keep=keep-a[i];
				}
			}
		for(i=1;i<=z;i++) cout << keep << " 0" << endl;
	}
	return 0;
}


Measured memory_bytes: 2688