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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int ok = n;
    int ng = -1;
    while (abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if (a[mid] >= 0) ok = mid;
        else ng = mid;
    }

    if (ok == 0){
        if (n == 2){
            cout << a[1] - a[0] << endl;
            cout << a[1] << " " << a[0] << endl;
            exit(0);
        }
        long long m = 0;
        m -= a[0];
        for (int i = 1; i < n; i++) m += abs(a[i]);
        cout << m << endl;
        cout << a[0] << " " << a[1] << endl;
        int next = a[0] - a[1];
        ok = 2;
        while (ok < n - 1){
            cout << next << " " << a[ok] << endl;
            next = next - a[ok];
            ok++;
        }
        cout << a.back() << " " << next << endl;
    }
    else if (ok == n){
        if (n == 2){
            cout << a[1] - a[0] << endl;
            cout << a[1] << " " << a[0] << endl;
            exit(0);
        }
        long long m = 0;
        m -= abs(a[n-1]);
        for (int i = 0; i < n - 1; i++) m += abs(a[i]);
        cout << m << endl;
        cout << a[n-1] << " " << a[n-2] << endl;
        int next = a[n-1] - a[n-2];
        ok = n-3;
        while (ok > 0){
            cout << next << " " << a[ok] << endl;
            next = next - a[ok];
            ok--;
        }
        cout << next << " " << a[0] << endl;
    }
    else {
        long long m = 0;
        for (int i = 0; i < n; i++) m += abs(a[i]);
        cout << m << endl;
        if (ok * 2 == n){
            int now = ok - 1;
            int next = 0;
            cout << a[ok] << " " << a[now] << endl;
            next = a[ok] - a[now];
            ok++;
            now--;
            while (ok < n && now >= 0){
                cout << a[now] << " " << next << endl;
                next = a[now] - next;
                cout << a[ok] << " " << next << endl;
                next = a[ok] - next;
                ok++;
                now--;
            }
        }
        else if (ok * 2 < n){
            int now = ok - 1;
            int next = 0;
            cout << a[now] << " " << a[ok] << endl;
            next = a[now] - a[ok];
            ok++;
            while (now + 1 != n - ok){
                cout << next << " " << a[ok] << endl;
                next = next - a[ok];
                ok++;
            }
            cout << a[ok] << " " << next << endl;
            next = a[ok] - next;
            ok++;
            now--;
            while (ok < n && now >= 0){
                cout << a[now] << " " << next << endl;
                next = a[now] - next;
                cout << a[ok] << " " << next << endl;
                next = a[ok] - next;
                ok++;
                now--;
            }
        }
        else {
            int now = ok - 1;
            int next = 0;
            cout << a[ok] << " " << a[now] << endl;
            next = a[ok] - a[now];
            now--;
            while (now + 1 != n - ok){
                cout << next << " " << a[now] << endl;
                next = next - a[now];
                now--;
            }
            cout << next << " " << a[now] << endl;
            next = next - a[now];
            ok++;
            now--;
            while (ok < n && now >= 0){
                cout << a[now] << " " << next << endl;
                next = a[now] - next;
                cout << a[ok] << " " << next << endl;
                next = a[ok] - next;
                ok++;
                now--;
            }
        }
    }
}

Measured memory_bytes: 2304