using System;
using System.Collections.Generic;
class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s1 = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            for (int i=0; i<n; i++) a[i] = int.Parse(s1[i]);

            int posSample = 0;
            int negSample = 0;
            int sum = 0;

            for (int i=0; i<n; i++)
            {
                if (a[posSample] < a[i]) posSample = i;
                if (a[negSample] > a[i]) negSample = i;
                sum += Math.Abs(a[i]);
            }

            if (a[posSample] < 0) //all sample is minus
            {
                Console.WriteLine(sum + a[posSample] * 2);
                int[] b = new int[n];
                int j = 0;
                for (int i=0; i<n; i++)
                {
                    if (i == posSample) continue;
                    b[j] = a[i];
                    j++;
                }
                b[n-1] = -1;
                int ans = a[posSample];
                for (int i=0; i<n-1; i++)
                {
                    if (b[i + 1] > 0)
                    {
                        Console.WriteLine(Math.Min(b[i], ans) + " " + Math.Max(b[i], ans));
                        ans = Math.Min(b[i], ans) - Math.Max(b[i], ans);
                    }
                    else{
                        Console.WriteLine(Math.Max(b[i], ans) + " " + Math.Min(b[i], ans));
                        ans = Math.Max(b[i], ans) - Math.Min(b[i], ans);
                    }
                }
            }
            else if (a[negSample] > 0) //all sample is plus
            {
                Console.WriteLine(sum - a[negSample] * 2);
                int[] b = new int[n];
                int j = 0;
                for (int i=0; i<n; i++)
                {
                    if (i == negSample) continue;
                    b[j] = a[i];
                    j++;
                }
                b[n-1] = -1;
                int ans = a[negSample];
                for (int i=0; i<n-1; i++)
                {
                    if (b[i + 1] > 0)
                    {
                        Console.WriteLine(Math.Min(b[i], ans) + " " + Math.Max(b[i], ans));
                        ans = Math.Min(b[i], ans) - Math.Max(b[i], ans);
                    }
                    else{
                        Console.WriteLine(Math.Max(b[i], ans) + " " + Math.Min(b[i], ans));
                        ans = Math.Max(b[i], ans) - Math.Min(b[i], ans);
                    }
                }
            }
            else{
                Console.WriteLine(sum);
                int[] b = new int[n];
                int j = 1;
                b[0] = a[posSample];
                for (int i=0; i<n; i++)
                {
                    if (i == negSample || i == posSample) continue;
                    b[j] = a[i];
                    j++;
                }
                b[n-1] = -1;
                int ans = a[negSample];
                for (int i=0; i<n-1; i++)
                {
                    if (b[i + 1] > 0)
                    {
                        Console.WriteLine(Math.Min(b[i], ans) + " " + Math.Max(b[i], ans));
                        ans = Math.Min(b[i], ans) - Math.Max(b[i], ans);
                    }
                    else{
                        Console.WriteLine(Math.Max(b[i], ans) + " " + Math.Min(b[i], ans));
                        ans = Math.Max(b[i], ans) - Math.Min(b[i], ans);
                    }
                }
            }
            
            
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 27080