#pragma GCC optimize ("O3,Ofast,inline,fast-math,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
#define int int64_t
#define double long double
#define MAXT numeric_limits<T>::max()
#define MINT numeric_limits<T>::min()
const int MAX=numeric_limits<int>::max();const int MIN=numeric_limits<int>::min();
const double EPS=1e-7;
const int MOD=1e9+7;
// typedef VVVPIDCS
#define vdef(t,T) typedef vector<t> V##T;typedef vector<V##T> VV##T;typedef vector<VV##T> VVV##T;
#define defall(xdef) xdef(int,I)xdef(double,D)xdef(char,C)xdef(string,S)
#define pdef0(t1,T1,t2,T2,t3,T3,t4,T4) typedef pair<t1,t2> P##T1##T2;vdef(P##T1##T2,P##T1##T2)typedef pair<t1,pair<t2,t3>> P##T1##T2##T3;vdef(P##T1##T2##T3,P##T1##T2##T3)typedef pair<t1,pair<t2,pair<t3,t4>>> P##T1##T2##T3##T4;vdef(P##T1##T2##T3##T4,P##T1##T2##T3##T4)
#define pdef1(t1,T1,t2,T2,t3,T3) pdef0(int,I,t1,T1,t2,T2,t3,T3)pdef0(double,D,t1,T1,t2,T2,t3,T3)pdef0(char,C,t1,T1,t2,T2,t3,T3)pdef0(string,S,t1,T1,t2,T2,t3,T3)
#define pdef2(t1,T1,t2,T2) pdef1(int,I,t1,T1,t2,T2)pdef1(double,D,t1,T1,t2,T2)pdef1(char,C,t1,T1,t2,T2)pdef1(string,S,t1,T1,t2,T2)
#define pdef3(t1,T1) pdef2(int,I,t1,T1)pdef2(double,D,t1,T1)pdef2(char,C,t1,T1)pdef2(string,S,t1,T1)
#define pdef4 defall(pdef3)
defall(vdef)pdef4
// template
#define TTT template<typename T>
#define TT2(T1,T2) template<typename T1,typename T2>
#define TT3(T1,T2,T3) template<typename T1,typename T2, typename T3>
#define VT vector<T>
#define VVT vector<VT>
#define PTT pair<T1,T2>
#define GT graph<T>
// use frequently
#define emb emplace_back
#define pub push_back
#define pob pop_back
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define tra(a,x) for(auto&a:x)
#define elif(c) else if(c)
#define si(vec) ((int)(vec).size())
#define all(vec) vec.begin(),vec.end()
#define lla(vec) vec.rbegin(),vec.rend()
#define range(vec,x,y) vec.begin()+x,vec.begin()+y
// make_pair
TT2(T1,T2) auto mp(const T1&a,const T2&b){return make_pair(a,b);}TT3(T1,T2,...Tail) auto mp(const T1&a,const T2&b,const Tail&...tail){return mp(a,mp(b,tail...));}
#define fi first
#define se second
#define fir fi
#define sec se.fi
#define thi se.se
#define firs fi
#define seco sec
#define thir thi.fi
#define four thi.se
// easy calculation
#define opall(calc) calc(+)calc(-)calc(*)calc(/)calc(%)calc(<<)calc(>>)calc(&)calc(|)calc(^)
#define opeq(op) TT2(T1,T2) T1 operator op##=(T1&l,const T2&r){return l=l op r;}
opall(opeq)
// mod
class modulo{public:int n;modulo(int _n=0):n(_n%MOD+(_n<0?MOD:0)){}modulo mod(){return modulo(n%MOD+(n<0?MOD:0));}modulo inv(){int a=n,b=MOD,u=0,v=1;while(a>1){u-=b/a*v;b%=a;swap(a,b);swap(u,v);}return modulo(v);}modulo&operator=(const modulo&m){n=m.n;return *this;}modulo&operator=(const int&m){n=modulo(m).n;return*this;}void operator++(signed _n){n=modulo(n+1).n;}void operator--(signed _n){n=modulo(n-1).n;}modulo&operator+(){return *this;}modulo&operator-(){n=modulo(-n).n;return *this;}};istream&operator>>(istream&is,modulo&m){is>>m.n;m=m.mod();return is;}ostream&operator<<(ostream&os,const modulo&m){os<<m.n;return os;}
#define m1c(op) modulo operator op(const int&l,const modulo&r){return modulo(l) op r;}modulo operator op(const modulo&l,const int&r){return l op modulo(r);}
#define m2c(op) modulo operator op(const modulo&l,const modulo&r){return modulo(l.n op r.n).mod();}m1c(op)
m2c(+)m2c(-)m2c(*)m2c(<)m2c(<=)m2c(>)m2c(>=)m2c(==)m2c(!=)
modulo operator/(const modulo&l,const modulo&r){return l*modulo(r).inv();}m1c(/)
modulo operator^(modulo l,modulo r){modulo a(1);while(r.n>0){if(r.n&1)a*=l;l*=l;r.n>>=1;}return a;}m1c(^)
// make_pair,vector calculation
#define pairveccalc(op) TT3(T1,T2,TT)PTT operator op(const PTT&p,const TT&c){return mp(p.fi op c,p.se op c);}TT3(T1,T2,TT)PTT operator op(const TT&c,const PTT&p){return mp(c op p.fi,c op p.se);}TT2(T1,T2)PTT operator op(const PTT l,const PTT&r){return mp(l.fi op r.fi,l.se op r.se);}TT2(T,TT)VT operator op(VT vec,const TT&c){tra(v,vec)v=v op c;return vec;}TT2(T,TT)VT operator op(const TT&c,VT vec){tra(v,vec)v=c op v;return vec;}TTT VT operator op(VT l,const VT&r){fou(i,0,min(si(l),si(r)))l[i]=l[i] op r[i];return l;}
opall(pairveccalc)
// iostream
#define in(T,...) T __VA_ARGS__;_in(__VA_ARGS__)
void _in(){}TT2(Head,...Tail) void _in(Head&head,Tail&&...tail){cin>>head;_in(forward<Tail>(tail)...);}
TTT void out(const T&a){cout<<a<<endl;}TT2(Head,...Tail) void out(const Head&head,Tail...tail){cout<<head<<" ";out(forward<Tail>(tail)...);}TTT void vout(const VT&vec){tra(v,vec)out(v);}TT2(T1,T2)istream&operator>>(istream&is,PTT&p){return is>>p.fi>>p.se;}TTT istream&operator>>(istream&is,VT&vec){tra(v,vec)is>>v;return is;}TT2(T1,T2) ostream&operator<<(ostream&os,const PTT&p){os<<p.fi<<" "<<p.se;return os;}TTT ostream&operator<<(ostream&os,const VT&vec){if(vec.empty())return os;;fou(i,0,si(vec)-1)os<<vec[i]<<" ";os<<vec[si(vec)-1];return os;}
// math
TTT T sign(T a){return (a>0)-(a<0);}
int gcd(const int&a,const int&b,const int&c){return b?gcd(b,a%b,0):a;}int gcd(const int&a,const int&b){return gcd(max(a,b),min(a,b),0);}
int lcm(const int&a,const int&b){return a/gcd(a,b)*b;}
int fact(const int&n){int r=1;fou(i,1,n+1)r*=i;return r;}
PII comb(const int&m,const int&n,const PII&nd){return (n==0)?nd:comb(m-1,n-1,mp(m,n)*nd);}int comb(const int&m,const int&n){PII p=comb(m,min(n,m-n),mp((int)1,(int)1));return p.fi/p.se;}
// vector,matrix
TTT T vecsum(const VT&vec,const int&l,const int&r){T sum=0;fou(i,l,r)sum+=vec[i];return sum;}
TTT T partof(T vec){return vec;}TT2(T,...Tail) T partof(T vec,const int&r,const int&l,const Tail&...tail){fou(i,0,l-r)vec[i]=vec[r+i];vec.erase(range(vec,l-r,si(vec)));fou(i,0,l-r)vec[i]=partof(vec[i],tail...);return vec;}
TTT T dot(const VT&vec1,const VT&vec2){int sum=0;fou(i,0,min(si(vec1),si(vec2)))sum+=vec1[i]*vec2[i];return sum;}TTT VVT dot(const VVT&mat1,const VVT&mat2){int h=si(mat1),w=si(mat2[0]);VVT mat(h,VI(w));fou(i,0,h)fou(j,0,w)fou(k,0,min(si(mat1[0]),si(mat2)))mat[i][j]+=mat1[i][k]*mat2[k][j];return mat;}
VVI eye(const int&n){VVI e(n,VI(n));fou(i,0,n)e[i][i]=1;return e;}
TTT VVT matpow(VVT mat,int n){int s=si(mat);VVT r=eye(s);while(n>0){if(n&1)r=dot(r,mat);mat=dot(mat,mat);n>>=1;}return r;}
#define sortcomp(vec,compXY) function<bool(decltype(vec[0]),decltype(vec[0]))>([&](auto&X,auto&Y){return compXY;})
TTT void sortup(VT&vec,function<bool(T&,T&)>f=[](T&x,T&y){return x<y;}){sort(all(vec),f);}
TTT void sortdown(VT&vec,function<bool(T&,T&)>f=[](T&x,T&y){return x<y;}){sort(lla(vec),f);}
TTT void erase_unique(VT&vec){vec.erase(unique(all(vec)),vec.end());}
TTT void rotation(VT&vec,const int&n){if(n>0)rotate(vec.begin(),vec.begin()+n,vec.end());if(n<0)rotate(vec.rbegin(),vec.rbegin()-n,vec.rend());}
TTT void mini(T&a,const T&b){a=min(a,b);}
TTT void maxi(T&a,const T&b){a=max(a,b);}
TTT int mine(VT&vec){T m=0;fou(i,1,si(vec))if(vec[i]<vec[m])m=i;return m;}
TTT int maxe(VT&vec){T m=0;fou(i,1,si(vec))if(vec[i]>vec[m])m=i;return m;}
// cumulated sum
TTT void cumsum(VT&vec){fou(i,1,si(vec))vec[i]+=vec[i-1];}TTT void cumsum(VVT&vec){fou(i,1,si(vec))vec[i]+=vec[i-1];fou(i,0,si(vec))cumsum(vec[i]);}
TTT T partsum(VT&vec,const int&l,const int&r){return (l==0)?vec[r-1]:vec[r-1]-vec[l-1];}TTT T partsum(VVT&vec,const int&l1,const int&r1,const int&l2,const int&r2){return (vec[r1-1][r2-1])-((l1==0)?0:vec[l1-1][r2-1])-((l2==0)?0:vec[r1-1][l2-1])+((l1==0||l2==0)?0:vec[l1-1][l2-1]);}
TTT void decumsum(VT&vec){int s=si(vec);fod(i,1,s)vec[i]-=vec[i-1];}TTT void decumsum(VVT&vec){fod(i,1,si(vec))vec[i]-=vec[i-1];fod(i,0,si(vec))decumsum(vec[i]);}
// string
int leven(string str1,string str2,int insert=1,int erase=1,int replace=1){int s1=si(str1),s2=si(str2);VVI d(s1+1,VI(s2+1));fou(i,0,s1+1)d[i][0]=i*insert;fou(j,0,s2+1)d[0][j]=j*erase;fou(i,1,s1+1)fou(j,1,s2+1){int diff=((str1[i-1]==str2[j-1])?0:1);d[i][j]=min({d[i-1][j]+insert,d[i][j-1]+erase,d[i-1][j-1]+replace*diff});}return d[s1][s2];}
int lcs(string str1,string str2){int s1=si(str1),s2=si(str2);VVI dp(s1+1,VI(s2+1));fou(i,0,s1)fou(j,0,s2){if(str1[i]==str2[j])dp[i+1][j+1]=dp[i][j]+1;else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);}return dp[s1][s2];}
// algorithm
TTT class BIT{VT tree;int n;public:BIT(int _n):n(_n){tree.resize(n);}void add(int x,T v){while(x<n){tree[x]+=v;x|=(x+1);}}T sum(int x){T v=0;while(x>=0){v+=tree[x];x=(x&(x+1))-1;}return v;}T part(int x,int y){return sum(y-1)-sum(x-1);}T get(int x){return part(x,x+1);}void set(int x,int y){add(x,-get(x)+y);}};
TTT class unionfind{public:VI par;VT wei;int n;unionfind(int _n):n(_n){par.resize(n);iota(all(par),1);wei.resize(n);}int get(const int&x){if(par[x]==(x+1))return x+1;else{int parent=sign(par[x])*get(abs(par[x])-1);wei[x]+=wei[abs(par[x])-1];return par[x]=parent;}}void get(int&x,int&y){x=get(x);y=get(y);}int weight(int x){get(x);return wei[x];}void unite(int x,int y,T w=0){w+=weight(x)-weight(y);get(x,y);if(abs(x)!=abs(y)){par[abs(y)-1]=x*sign(y);wei[abs(y)-1]=w;}}void separate(int x,int y,T w=0){w+=weight(x)-weight(y);get(x,y);if(abs(x)!=abs(y)){par[abs(y)-1]=-x*sign(y);wei[abs(y)-1]=w;}}int same(int x,int y){get(x,y);return (x==y)-(x==-y);}T diff(int x,int y){return weight(y)-weight(x);}};
TTT int binarysearch(const VT&vec,const T&n,const char&c){
  int left=-1;int right=si(vec);bool outleft=(c=='d'||c=='U');int getmin=(c=='u'||c=='d')?1:-1;
  while(right-left>1){
    int mid=left+(right-left)/2;
    bool OK=vec[mid]*getmin>=n*getmin;
    if(outleft==OK) left=mid;else right=mid;
  }
  return outleft?left:right;
}

// graph class
TTT class graph{public:struct edge{int from,to;T cost;};int n;vector<edge>edges;VVI g;bool di;function<bool(int)>ignore;graph(int _n):n(_n){g.resize(n);ignore=nullptr;}virtual int add(int from,int to,T cost)=0;void clear(){edges.resize(0);g=VVI(n);};virtual void set_ignore_edge_rule(const function<bool(int)> &f){ignore=f;}virtual void reset_ignore_edge_rule(){ignore = nullptr;}};
TTT class undigraph:public GT{public:using GT::edges;using GT::g;using GT::n;using GT::di;undigraph(int n):GT(n){di=false;}int add(int from,int to,T cost=1){int id=si(edges);g[from].emb(id);g[to].emb(id);edges.pub({from,to,cost});return id;}};
TTT class digraph:public GT{public:using GT::edges;using GT::g;using GT::n;using GT::di;using GT::ignore;digraph(int _n):GT(_n){di=true;}int add(int from,int to,T cost=1){int id=si(edges);g[from].emb(id);edges.pub({from,to,cost});return id;}digraph<T>reverse()const{digraph<T> rev(n);tra(e,edges)rev.add(e.to,e.from,e.cost);if(ignore!=nullptr){rev.set_ignore_edge_rule([&](int id){return ignore(id);});}return rev;}};
// shortest path
TTT VT dijkstra(const GT&g,const int&start){VT d(g.n,MAXT);priority_queue<pair<T,int>,vector<pair<T,int>>,greater<pair<T,int>>>s;d[start]=0;s.emplace(d[start],start);while(!s.empty()){T expected=s.top().fi;int from=s.top().se;s.pop();if(d[from]<expected)continue;tra(id,g.g[from]){auto e=g.edges[id];int to=e.from^e.to^from;if(d[from]+e.cost<d[to]){d[to]=d[from]+e.cost;s.emplace(d[to],to);}}}return d;}
TTT VT bellman(const GT&g,const int&start){VT d(g.n,MAXT);d[start]=0;bool nl=false;VI upd_b(1,start);int i=0;while(!upd_b.empty()&&i<g.n){VI upd;tra(from,upd_b){tra(id,g.g[from]){auto e=g.edges[id];int to=e.from^e.to^from;if(d[to]>d[from]+e.cost){d[to]=d[from]+e.cost;upd.emb(to);if(i==g.n-1){d[to]=MINT;nl=true;}}}}upd_b=upd;i++;}if(nl){i=0;while(!upd_b.empty()&&i<g.n-1){VI upd;tra(from,upd_b){tra(id,g.g[from]){auto e=g.edges[id];int to=e.from^e.to^from;if(d[to]!=MINT){d[to]=MINT;upd.emb(to);}}}upd_b=upd;i++;}}return d;}
// matrix graph
TTT VVT matrix_of_graph(const GT&g){VVT mat(g.n,VT(g.n,MAXT));fou(from,0,g.n){tra(id,g.g[from]){auto e=g.edges[id];int to=e.from^e.to^from;mat[from][to]=e.cost;}}return mat;}
TTT VVT warshall(VVT mat){fou(k,0,si(mat))fou(i,0,si(mat))fou(j,0,si(mat))mat[i][j]=(mat[i][k]==MAXT||mat[k][j]==MAXT)?mat[i][j]:min(mat[i][j],mat[i][k]+mat[k][j]);return mat;}
// minimum spanning tree
TTT T prim(GT&g,const int&start=0){vector<pair<T,PII>> cft;T total = 0;VI used(g.n,0);priority_queue<pair<T,PII>,vector<pair<T,PII>>,greater<pair<T,PII>>>s;s.emplace(mp(0,-1,start));while(!s.empty()){T cost=s.top().fi;int fromfrom=s.top().se.fi,from=s.top().se.se;s.pop();if(used[from])continue;used[from]=true;total+=cost;if(fromfrom>-1)cft.emb(mp(cost,fromfrom,from));tra(id,g.g[from]){auto e=g.edges[id];int to=e.from^e.to^from;s.emplace(mp(e.cost,from,to));}}g.clear();tra(a,cft)g.add(a.sec,a.thi,a.fir);return total;}
TTT T kruskal(undigraph<T>&g){vector<pair<T,PII>> cft;T total=0;sortup(g.edges,sortcomp(g.edges,X.cost<Y.cost));unionfind<int>uf(g.n);tra(e,g.edges)if(uf.same(e.from,e.to)==0){total+=e.cost;uf.unite(e.from,e.to);cft.emb(mp(e.cost,e.from,e.to));}g.clear();tra(a,cft)g.add(a.sec,a.thi,a.fir);return total;}
//  topological sort
TTT VI topsort(const digraph<T>&g){
  VI deg(g.n, 0);
  fou(id,0,si(g.edges)){
    if(g.ignore!=nullptr&&g.ignore(id))continue;
    deg[g.edges[id].to]++;
  }
  vector<int> x;
  fou(i,0,g.n)if(deg[i]==0)x.emb(i);
  fou(ptr,0,si(x)){
    int i = x[ptr];
    for(int id:g.g[i]){
      if(g.ignore!=nullptr&&g.ignore(id))continue;
      auto &e=g.edges[id];int to=e.to;
      if(--deg[to]==0)x.emb(to);
    }
  }
  if(si(x)!=g.n)return VI();
  return x;
}




// todo
// トポロジカルソート
// SPFA
// 最大フロー、２部グラフ
// 区間加算bit
// vecsum引数1

class time_measure{chrono::system_clock::time_point start;public:time_measure():start(chrono::system_clock::now()){}void time(){out(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()-start).count(),"ms");}};



signed main(){IOS;
  in(int,n);
  VI a(n);
  cin>>a;
  int ans=0;
  VPII xy(n-1);

  sortup(a);
  VI b(n);
  fou(i,0,n) b[i]=abs(a[i]);

  if(sign(a[0])==1&&sign(a[n-1])==1){
    ans=a[0];
    fou(i,0,n-2) {
      xy[i]=mp(ans,a[i+1]);
      ans-=a[i+1];
    }
    xy[n-2]=mp(a[n-1],ans);
    ans=a[n-1]-ans;
  }
  elif(sign(a[0])==-1&&sign(a[n-1])==-1){
    ans=a[n-1];
    fou(i,0,n-1) {
      xy[i]=mp(ans,a[n-i-2]);
      ans-=a[n-i-2];
    }
  }
  else{
    ans=a[0];
    int cnt=0;
    bool flag=true;
    fod(i,1,n){
      if(i==1){
        flag=false;
        xy[cnt]=mp(a[i],ans);
        cnt++;
        ans=a[i]-ans;
        break;
      }
      if(a[i-1]>=0) {
        xy[cnt]=mp(ans,a[i]);
        cnt++;
        ans-=a[i];
      }
      else {
        xy[cnt]=mp(a[i],ans);
        cnt++;
        ans=a[i]-ans;
        break;
      }
    }
    if(flag)fou(i,1,n){
      if(a[i+1]<0) {
        xy[cnt]=mp(ans,a[i]);
        cnt++;
        ans-=a[i];
      }
      else {
        xy[cnt]=mp(ans,a[i]);
        cnt++;
        ans-=a[i];
        break;
      }
    }
  }
  out(ans);
  vout(xy);

}

Measured memory_bytes: 4992