using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private struct Pair<T> { public T x, y; public Pair(T x, T y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        if (N == 2)
        {
            int a = NextInt();
            int b = NextInt();
            if (a > b) { Console.WriteLine(a - b); Console.WriteLine(a + " " + b); }
            else { Console.WriteLine(b - a); Console.WriteLine(b + " " + a); }
            return;
        }
        //デカい負を引くと良くなる
        //正を1つ残して後全部ふにする
        int[] A = LineInt();
        Array.Sort(A);
        int max = A.Max();
        PriorityQueue<int, int> sei = new PriorityQueue<int, int>();
        PriorityQueue<int, int> fu = new PriorityQueue<int, int>();
        List<Pair<int>> answer = new List<Pair<int>>();
        int i = 0;
        sei.Add(A[N - 1], A[N - 1]);
        fu.Add(A[0], A[0]);
        for (i = 1; i < N - 1; i++)
        {
            if (A[i] > 0)
            {
                int a = A[i];
                int b = fu.Take();
                answer.Add(new Pair<int>(b, a));
                fu.Add(b - a, b - a);
            }
            else
            {
                fu.Add(A[i], A[i]);
            }
        }
        //while (sei.Count() != 1)
        //{
        //    int a = sei.Take();
        //    int b = fu.Take();
        //    answer.Add(new Pair<int>(b, a));
        //    fu.Add(b - a, b - a);
        //}


        //最後に足す

        while (fu.Count() != 0)
        {
            int a = sei.Take();
            int b = fu.Take();
            answer.Add(new Pair<int>(a, b));
            sei.Add(a - b, a - b);
        }
        Console.WriteLine(sei.Peek());
        foreach (var p in answer) Console.WriteLine(p.x + " " + p.y);

    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}

public class PriorityQueue<Tkey, Tvalue> where Tkey : IComparable
{
    private List<Tkey> keys = new List<Tkey>();
    private List<Tvalue> values = new List<Tvalue>();
    private int size = 0;
    private bool Descending;
    private int Compare(Tkey a, Tkey b) { return (Descending ? a.CompareTo(b) : b.CompareTo(a)); }

    public PriorityQueue(bool b = true) { Clear(); Descending = b; }
    public int Count() { return size; }
    public void Clear() { keys = new List<Tkey>(); values = new List<Tvalue>(); size = 0; }
    public void Add(Tkey e, Tvalue v)
    {
        keys.Add(e);
        values.Add(v);
        int x = size;
        size += 1;
        while (x != 0)
        {
            int par = (x % 2 == 0 ? x - 2 : x - 1) / 2;
            if (Compare(keys[par], e) <= 0) break;
            Tkey a = keys[x]; keys[x] = keys[par]; keys[par] = a;
            Tvalue b = values[x]; values[x] = values[par]; values[par] = b;
            x = par;
        }
    }
    public void Poll()
    {
        Tkey k = keys[size - 1];
        Tvalue v = values[size - 1];
        int x = 0;
        size--;
        if (size == 0) { Clear(); return; }
        keys.RemoveAt(size);
        values.RemoveAt(size);
        while (true)
        {
            int l = x * 2 + 1;
            int r = x * 2 + 2;
            if (size - 1 < l) break;
            int y = 0;
            if (size - 1 == l) { y = l; }
            else if (Compare(keys[l], keys[r]) == 1) { y = r; }
            else { y = l; }
            if (Compare(keys[y], k) > 0) break;
            keys[x] = keys[y];
            values[x] = values[y];
            x = y;
        }
        keys[x] = k;
        values[x] = v;
    }
    public Tvalue Take() { Tvalue ret = values[0]; Poll(); return ret; }
    public Tvalue Peek() { return values[0]; }
    public void Debug()
    {
        Console.Write("key   : ");
        foreach (var k in keys) Console.Write(k + " ");
        Console.WriteLine();
        Console.Write("value : ");
        foreach (var k in values) Console.Write(k + " ");
        Console.WriteLine();
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 34032