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

#define PI 3.1415926535
#define MOD 1000000007
#define pb push_back
#define mp make_pair
//#define f first
//#define s second
#define FOR(i,x,y) for(int i=x;i<y;i++)
#define fill(a)  memset(a, 0, sizeof (a))
#define in(n) scanf("%d",&n)
#define out(n) printf("%d\n",n)
#define SORT(v)  sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define MAX(v) *max_element(v.begin(), v.end())
#define MIN(v) *min_element(v.begin(), v.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout << (#x) << " is " << (x) << endl;
const long long int MAXX = 15e6;
const long long int MINN = 1e2;
const long long int inf = 1e7;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector< iii > viii;


ll lcm(ll a, ll b) {
   return a / __gcd(a, b) * b;
}
int XOR(int x, int y){
  return (x | y) & (~x | ~y);
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
    return (a.second < b.second);
}
// __builtin_popcount(x)  - Returns the number of set bits in x
const long long int N = 4e6+5;
const int MAXN = 105;
int binsearch(int lo, int hi){
	while(lo<hi){
		int mid=(lo+hi)/2;
		if((mid))   // check(mid)
			hi=mid;
		else
			lo=mid+1;
	}
	return lo;
}
ll power(ll x,ll y){
    ll res=1;
    while(y>0){
      if(y&1) res=(res*x)%MOD;

      y/=2;
      x=(x*x)%MOD;
    }
    return res%MOD;
}
vi v1,v2;
vii ans;
map<ii,int> m;
int main(){
      FAST
      int n,i,j,curr=0,anss=0;
      cin>>n;
      int a[n+1];
      for(i=1;i<=n;i++){
          cin>>a[i];
          if(a[i]>=0) v1.pb(a[i]);
          else v2.pb(a[i]);
      }
      sort(v1.begin(),v1.end());
      sort(v2.begin(),v2.end());
      if(v1.size()==1){
          curr=v1[0];
          for(i=0;i<v2.size();i++){
              ans.pb({curr,v2[i]});
              curr=curr-v2[i];
          }
          anss=curr;
      }
      else if(v1.size()==0){
          curr=v2.back();
          for(i=0;i<v2.size()-1;i++){
              ans.pb({curr,v2[i]});
              curr=curr-v2[i];
        }

          anss=curr;

      }
      else{
          if(v2.size()==0){
              curr=v1[0];
              for(i=1;i<v1.size()-1;i++){
                  ans.pb({curr,v1[i]});
                  curr-=v1[i];
              }
              ans.pb({v1.back(),curr});
              curr= v1.back()-curr;
          }
          else if(v2.size()==1){
              curr=v2[0];
              for(i=0;i<v1.size()-1;i++){
                  ans.pb({curr,v1[i]});
                  curr-=v1[i];
              }
              ans.pb({v1.back(),curr});
              curr= v1.back()-curr;
          }
          else{
              curr=v2[0];
              for(i=0;i<v1.size()-1;i++){
                  ans.pb({curr,v1[i]});
                  curr-=v1[i];
              }
              int cc=v1.back();
              ans.pb({cc,curr});
              curr= cc-curr;
              for(i=1;i<v2.size();i++){
                  ans.pb({curr,v2[i]});
                  curr-=v2[i];
              }
          }
      }
      cout<<curr<<"\n";
      for(i=0;i<ans.size();i++)
      cout<<ans[i].first<<' '<<ans[i].second<<"\n";


      return 0;
}


Measured memory_bytes: 5488