#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    ll n , x; cin >> n;
    ll  mnp = 0  , mnn  = 0,  sump = 0 , sumn= 0, ans = 0 , nill = 0;
    vll pos , neg;
    for(int i = 0 ;i < n ; i++){
        cin >> x;
        if(x > 0){
            pos.pb(x);
            sump += x;
        }
        else if(x == 0){
            nill++;
        }
        else{
            neg.pb(x);
            sumn += x;
        }
    }
    
    
    if(neg.size() == 0){
        for(int i =  0 ;i < nill ; i++)
            pos.pb(0);
        sort(all(pos));
        mnp = pos[0];
        cout << sump-2*mnp << endl;
        for(int i = 0 ;i < pos.size()-2 ; i++){
            cout << mnp << " " << pos[pos.size()-1-i] << endl;
            mnp -= pos[pos.size()-1-i];
        }
        cout << pos[1] << " " << mnp << endl;
    }
    else if(pos.size() == 0){
        for(int i = 0 ;i < nill ; i++)
            neg.pb(0);
        sort(all(neg));
        reverse(all(neg));

        mnn = neg[0];
        cout << -1*sumn + 2*mnn << endl;
        for(int i = 0 ;i < neg.size()-1 ; i++){
            cout << mnn << " " << neg[neg.size()-1-i] << endl;
            mnn -= neg[neg.size()-1-i];
        }
    }
    else if(pos.size() == 1){
        cout << sump - sumn << endl;
        mnp = pos[0];
        for(int i = 0 ;i < nill ; i++)
            neg.pb(0);
        for(int i = 0 ; i < neg.size() ; i++){
            cout << mnp << " " << neg[i] << endl;
            mnp -= neg[i];
        }
    }
    else if(neg.size() == 1){
        for(int i = 0 ;i < nill ; i++)
            pos.pb(0);
        sort(all(pos));
        cout << sump - sumn << endl;
        mnn = neg[0];
        for(int i = 1 ;i < pos.size(); i++){
            cout << mnn << " " << pos[i] << endl;
            mnn -= pos[i];
        }
        cout << pos[0] << " " << mnn << endl;
    }
    else
    {
        for(int i = 0 ;i < nill ; i++)
            pos.pb(0);
        
        cout << sump - sumn << endl;
        mnn = neg[0];
        for(int i = 1 ;i < pos.size() ; i++){
            cout << mnn << " " << pos[i] << endl;
            mnn -= pos[i];
        }
        neg[0] = mnn;
        mnp = pos[0];
        for(int i = 0 ;i < neg.size() ; i++){
            cout << mnp << " " << neg[i] << endl;
            mnp -= neg[i];
        }

    }
    
    return 0;
}

Measured memory_bytes: 2804