#include<bits/stdc++.h>
using namespace std;
int n;
int a[100005];
vector<pair<int,int> > pairs;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=n-1;i>=2;i--){
		if(a[i]<0) break;
		pairs.push_back(make_pair(a[1],a[i]));
		a[1]-=a[i];
	}
	for(int i=2;i<=n-1;i++){
		if(a[i]>=0) break;
		pairs.push_back(make_pair(a[n],a[i]));
		a[n]-=a[i];
	}
	int ans=a[n]-a[1];
	pairs.push_back(make_pair(a[n],a[1]));
	cout<<ans<<endl;
	for(int i=0;i<pairs.size();i++){
		cout<<pairs[i].first<<" "<<pairs[i].second<<endl;
	}
}