using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			long[] a = cin.ArrayLong(n);
			if (n == 2) {
				Console.WriteLine(Math.Max(a[0], a[1]) - Math.Min(a[0], a[1]));
				Console.WriteLine($"{Math.Max(a[0], a[1])} {Math.Min(a[0], a[1])}");
				return;
			}

			var ms = new PriorityQueue<long>(n);
			var ps = new PriorityQueue<long>(n, true);
			for (int i = 0; i < n; i++) {
				if (a[i] >= 0) {
					ps.Enqueue(a[i]);
				} else {
					ms.Enqueue(a[i]);
				}
			}

			var sb = new StringBuilder();
			long ans = 0;
			if (ps.Count == 0) {
				long m1 = ms.Dequeue();
				long m2 = ms.Dequeue();
				sb.AppendLine($"{m1} {m2}");
				ans += m1 - m2;
				while (ms.Count > 0) {
					long m = ms.Dequeue();
					sb.AppendLine($"{ans} {m}");
					ans = ans - m;
				}
			} else if (ms.Count == 0) {
				long p1 = ps.Dequeue();
				long p2 = ps.Dequeue();
				ans = p1 - p2;
				sb.AppendLine($"{p1} {p2}");
				while (ps.Count > 1) {
					long p = ps.Dequeue();
					sb.AppendLine($"{ans} {p}");
					ans = ans - p;
				}

				long pl = ps.Dequeue();
				sb.AppendLine($"{pl} {ans}");
				ans = pl - ans;
			} else {
				long pp = ps.Dequeue();
				long mm = ms.Dequeue();
				while (ms.Count > 0) {
					long m = ms.Dequeue();
					sb.AppendLine($"{pp} {m}");
					pp = pp - m;
				}

				while (ps.Count > 0) {
					long p = ps.Dequeue();
					sb.AppendLine($"{mm} {p}");
					mm = mm - p;
				}

				sb.AppendLine($"{pp} {mm}");
				ans = pp - mm;
			}

			Console.WriteLine(ans);
			Console.WriteLine(sb.ToString());
		}
	}

	public class PriorityQueue<T>
	{
		private readonly List<T> heap_;
		private readonly Comparison<T> comparison_;
		private readonly bool reverses_;

		public T Top => heap_[0];
		public int Count => heap_.Count;

		public PriorityQueue(bool reverses = false)
			: this(Comparer<T>.Default, reverses) { }

		public PriorityQueue(int capacity, bool reverses = false)
			: this(capacity, Comparer<T>.Default.Compare, reverses) { }

		public PriorityQueue(IComparer<T> comparer, bool reverses = false)
			: this(16, comparer.Compare, reverses) { }

		public PriorityQueue(Comparison<T> comparison, bool reverses = false)
			: this(16, comparison, reverses) { }

		public PriorityQueue(
			int capacity,
			Comparison<T> comparison,
			bool reverses = false)
		{
			heap_ = new List<T>(capacity);
			comparison_ = comparison;
			reverses_ = reverses;
		}

		public void Enqueue(T item)
		{
			int c = heap_.Count;
			heap_.Add(item);
			while (c > 0) {
				int p = (c - 1) >> 1;
				if (Compare(p, c) < 0) {
					Swap(p, c);
				} else {
					break;
				}

				c = p;
			}
		}

		public T Dequeue()
		{
			T ret = heap_[0];
			int n = heap_.Count - 1;

			heap_[0] = heap_[n];
			heap_.RemoveAt(n);
			for (int p = 0, c; (c = (p << 1) + 1) < n; p = c) {
				if (c != n - 1 && Compare(c + 1, c) > 0) {
					++c;
				}

				if (Compare(p, c) < 0) {
					Swap(p, c);
				} else {
					break;
				}
			}

			return ret;
		}

		private int Compare(int x, int y)
			=> comparison_(heap_[x], heap_[y]) * (reverses_ ? -1 : 1);

		private void Swap(int x, int y)
		{
			var t = heap_[x];
			heap_[x] = heap_[y];
			heap_[y] = t;
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 39396