#include<bits/stdc++.h>

using namespace std;

int n,m,ans,A,B,BA,a[120000];

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i){
		scanf("%d",a+i);
	}
	sort(a+1,a+n+1);
	ans=-a[1]+a[n]; for (int i=2;i<n;++i) ans+=abs(a[i]);
	printf("%d\n",ans);
	int x=a[1],y=a[n];
	for (int i=2;i<n;++i)
		if (a[i]<0){printf("%d %d\n",y,a[i]); y-=a[i];}
		else{printf("%d %d\n",x,a[i]); x-=a[i];}
	printf("%d %d\n",y,x);
	
	return 0;
}
			