from collections import defaultdict, deque
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
N = int(input())
A = sorted(inpl())
if A[-1] < 0:
    print(A[-1] - sum(A[:-1]))
    for i in range(N-2, -1, -1):
        print(A[-1], A[i])
        A[-1] -= A[i]
else:
    print(sum(map(abs, A[1:])) - A[0])
    for i in range(N-2, 0, -1):
        a = A[i]
        if a > 0:
            print(A[0], a)
            A[0] -= a
        else:
            print(A[-1], a)
            A[-1] -= a
    print(A[-1], A[0]) from collections import defaultdict, deque import sys sys def inpl(): return list(map(int, input().split())) inpl N = int(input()) N int(input()) int input() input A = sorted(inpl()) A sorted(inpl()) sorted inpl() inpl if A[-1] < 0:
    print(A[-1] - sum(A[:-1]))
    for i in range(N-2, -1, -1):
        print(A[-1], A[i])
        A[-1] -= A[i]
else:
    print(sum(map(abs, A[1:])) - A[0])
    for i in range(N-2, 0, -1):
        a = A[i]
        if a > 0:
            print(A[0], a)
            A[0] -= a
        else:
            print(A[-1], a)
            A[-1] -= a
    print(A[-1], A[0]) A[-1] < 0 A[-1] A -1 0 print(A[-1] - sum(A[:-1])) print A[-1] - sum(A[:-1]) A[-1] A -1 sum(A[:-1]) sum A[:-1] A :-1 -1 for i in range(N-2, -1, -1):
        print(A[-1], A[i])
        A[-1] -= A[i] i range(N-2, -1, -1) range N-2 N 2 -1 -1 print(A[-1], A[i]) print A[-1] A -1 A[i] A i A[-1] -= A[i] A[-1] A -1 A[i] A i print(sum(map(abs, A[1:])) - A[0]) print sum(map(abs, A[1:])) - A[0] sum(map(abs, A[1:])) sum map(abs, A[1:]) map abs A[1:] A 1: 1 A[0] A 0 for i in range(N-2, 0, -1):
        a = A[i]
        if a > 0:
            print(A[0], a)
            A[0] -= a
        else:
            print(A[-1], a)
            A[-1] -= a
     i range(N-2, 0, -1) range N-2 N 2 0 -1 a = A[i] a A[i] A i if a > 0:
            print(A[0], a)
            A[0] -= a
        else:
            print(A[-1], a)
            A[-1] -= a
     a > 0 a 0 print(A[0], a) print A[0] A 0 a A[0] -= a A[0] A 0 a print(A[-1], a) print A[-1] A -1 a A[-1] -= a A[-1] A -1 a print(A[-1], A[0]) print A[-1] A -1 A[0] A 0 A = sorted(inpl()) sorted(inpl()) A a = A[i] A[i] a def inpl(): return list(map(int, input().split())) def inpl(): return list(map(int, input().split())) inpl N = int(input()) int(input()) N
from collections import defaultdict, deque
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
N = int(input())
A = sorted(inpl())
if A[-1] < 0:
    print(A[-1] - sum(A[:-1]))
    for i in range(N-2, -1, -1):
        print(A[-1], A[i])
        A[-1] -= A[i]
else:
    print(sum(map(abs, A[1:])) - A[0])
    for i in range(N-2, 0, -1):
        a = A[i]
        if a > 0:
            print(A[0], a)
            A[0] -= a
        else:
            print(A[-1], a)
            A[-1] -= a
    print(A[-1], A[0])
