//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    int n, M;cin >> n;
    VI P, Z, N;

    int n_p=0, n_n=0, n_z=0;

    vector<pair<int, int> > ANS;
    
    
    REP(i,n)
    {
        int a;cin >> a;
        if (a<0) 
        {
            n_n++;
            N.push_back(a);
        }
        else if (a>0) 
        {
            n_p++;
            P.push_back(a);
        }
        else 
        {
            n_z++;
            Z.push_back(a);;
        }
    }

    //dump(n_n);dump(n_p);dump(n_z);

    REP(i,n-1)
    {
        if (n_z >0)
        {
            Z.erase(Z.begin());
            n_z--;
            if (n_p==0 && n_n==0)
            {
                ANS.push_back(make_pair(0, 0));
                if (n_z==1)
                {
                    cout <<0<<endl;
                    break;
                }
            }
            else if (n_n==1 && n_z==0 && n_p==0)
            {
                ANS.push_back(make_pair(0, N.front()));
                cout << -N.front() << endl;
                break;
            }
            else if (n_p==1 &&n_z==0 && n_n==0)
            {
                ANS.push_back(make_pair(P.front(), 0));
                cout << P.at(0) << endl;
                break;
            }
            else if (n_n>=1 && n_p==0)
            {
                ANS.push_back(make_pair(0, N.front()));
                n_p++;
                P.push_back(-N.at(0));
                N.erase(N.begin());
                n_n--;
            }
            
            else if (n_p>=1 && n_n==0)
            {
                ANS.push_back(make_pair(0, P.front()));
                n_n++;
                N.push_back(-P.at(0));
                P.erase(P.begin());
                n_p--;
            }
            else if (n_n>=1 && n_p>=1)
            {
                ANS.push_back(make_pair(P.front(), 0));
            }
        }

        else if (n_p==0)
        {
            if (n_n>2)
            {   
                SORT(N);
                ANS.push_back(make_pair(N.back(), N.front()));
                int num = N.back()-N.front();
                if (num>0)
                {
                    P.push_back(num);
                    n_p++;
                }
                else if (num==0)
                {
                    Z.push_back(0);
                    n_z++;
                }
                else
                {
                    cout << "error" << endl;
                }
                N.erase(N.end()-1);
                N.erase(N.begin());
                n_n-=2;
            }
            else if (n_n==2)
            {
                ANS.push_back(make_pair(min(N.at(0), N.at(1)), max(N.at(0), N.at(1))));
                cout << abs(N.at(0)-N.at(1)) << endl;
                break;
            }
        }
        else if (n_n==0)
        {
            if (n_p>2)
            {

            SORT(P);
            ANS.push_back(make_pair(P.front(), P.back()));
            int num = P.front()-P.back(); 
            if (num<0)
            {
                N.push_back(num);
                n_n++;
            }
            else if (num==0)
            {
                Z.push_back(0);
                n_z++;
            }
            P.erase(P.end()-1);
            P.erase(P.begin());
            n_p-=2;
            }
            else if (n_p==2)
            {
                ANS.push_back(make_pair(max(P.at(0), P.at(1)), min(P.at(0), P.at(1))));
                cout << abs(P.at(0)-P.at(1)) << endl;
            }
        }
        else if (n_n==n_p)
        {
            ANS.push_back(make_pair(P.front(), N.front()));
            P.at(0) -= N.front();
            N.erase(N.begin());
            n_n--;
            if (n_n==0)
            {
                M = P.at(0);
                cout << M << endl;
                break;
            }
        }

        else if (n_n > n_p)
        {// - > +
            ANS.push_back(make_pair(P.front(), N.front()));
            P.at(0) -= N.front();
            N.erase(N.begin());
            n_n--;
        }
        else if (n_p > n_n)
        {// + > -
            ANS.push_back(make_pair(N.front(), P.front()));
            N.at(0) -= P.front();
            P.erase(P.begin());
            n_p--;
        }
    }
    REP(i, n-1)
    {
        cout << ANS.at(i).first << " " << ANS.at(i).second << endl;
    }

    return 0;
}



Measured memory_bytes: 3444