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

int main() {
    int n;
    vector<long long int> V;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        V.push_back(tmp);
    }
    sort(V.begin(), V.end());
    long long int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i == 0)
            ans -= V[i];
        else if (i == n - 1)
            ans += V[i];
        else
            ans += abs(V[i]);
    }
    cout << ans << "\n";
    for (int i = 1; i < n - 1; i++) {
        if (V[i] >= 0) {
            cout << V[0] << " " << V[i] << "\n";
            V[0] -= V[i];
        }
        else {
            cout << V[n - 1] << " " << V[i] << "\n";
            V[n - 1] -= V[i];
        }
    }
    cout << V[n - 1] << " " << V[0] << "\n";
}
