from collections import deque
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
p = sum(1 for a in A if a > 0)
if A[-1] > 0:
    print(sum(A[:-1]) - A[-1])
    k = A[-1]
    for a in A[:-2]:
        print(k, a)
        k -= a
    print(A[-2], k)

elif A[0] < 0:
    print(A[0] - sum(A[1:]))
    k = A[0]
    for a in A[1:]:
        print(k, a)
        k -= a
else:
    print(sum(abs(a) for a in A))
    A = deque(A)
    k = A.pop()
    for _ in range(p-1):
        t = A.popleft()
        print(k, t)
        k -= t
    t = A.popleft()
    print(t, k)
    t -= k
    for a in A:
        print(t, a)
        t -= a from collections import deque N = int(input()) N int(input()) int input() input A = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split A.sort(reverse = True) A.sort A sort reverse = True reverse True p = sum(1 for a in A if a > 0) p sum(1 for a in A if a > 0) sum 1 if A[-1] > 0:
    print(sum(A[:-1]) - A[-1])
    k = A[-1]
    for a in A[:-2]:
        print(k, a)
        k -= a
    print(A[-2], k)

elif A[0] < 0:
    print(A[0] - sum(A[1:]))
    k = A[0]
    for a in A[1:]:
        print(k, a)
        k -= a
else:
    print(sum(abs(a) for a in A))
    A = deque(A)
    k = A.pop()
    for _ in range(p-1):
        t = A.popleft()
        print(k, t)
        k -= t
    t = A.popleft()
    print(t, k)
    t -= k
    for a in A:
        print(t, a)
        t -= a A[-1] > 0 A[-1] A -1 0 print(sum(A[:-1]) - A[-1]) print sum(A[:-1]) - A[-1] sum(A[:-1]) sum A[:-1] A :-1 -1 A[-1] A -1 k = A[-1] k A[-1] A -1 for a in A[:-2]:
        print(k, a)
        k -= a
     a A[:-2] A :-2 -2 print(k, a) print k a k -= a k a print(A[-2], k) print A[-2] A -2 k elif A[0] < 0:
    print(A[0] - sum(A[1:]))
    k = A[0]
    for a in A[1:]:
        print(k, a)
        k -= a A[0] < 0 A[0] A 0 0 print(A[0] - sum(A[1:])) print A[0] - sum(A[1:]) A[0] A 0 sum(A[1:]) sum A[1:] A 1: 1 k = A[0] k A[0] A 0 for a in A[1:]:
        print(k, a)
        k -= a a A[1:] A 1: 1 print(k, a) print k a k -= a k a print(sum(abs(a) for a in A)) print sum(abs(a) for a in A) sum abs(a) abs a A = deque(A) A deque(A) deque A k = A.pop() k A.pop() A.pop A pop for _ in range(p-1):
        t = A.popleft()
        print(k, t)
        k -= t
     _ range(p-1) range p-1 p 1 t = A.popleft() t A.popleft() A.popleft A popleft print(k, t) print k t k -= t k t t = A.popleft() t A.popleft() A.popleft A popleft print(t, k) print t k t -= k t k for a in A:
        print(t, a)
        t -= a a A print(t, a) print t a t -= a t a N = int(input()) int(input()) N k -= t t k k -= a a k k = A.pop() A.pop() k k = A[0] A[0] k A = list(map(int, input().split())) list(map(int, input().split())) A k = A[-1] A[-1] k t = A.popleft() A.popleft() t t -= a a t k -= a a k p = sum(1 for a in A if a > 0) sum(1 for a in A if a > 0) p A = deque(A) deque(A) A t -= k k t t = A.popleft() A.popleft() t
from collections import deque
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
p = sum(1 for a in A if a > 0)
if A[-1] > 0:
    print(sum(A[:-1]) - A[-1])
    k = A[-1]
    for a in A[:-2]:
        print(k, a)
        k -= a
    print(A[-2], k)

elif A[0] < 0:
    print(A[0] - sum(A[1:]))
    k = A[0]
    for a in A[1:]:
        print(k, a)
        k -= a
else:
    print(sum(abs(a) for a in A))
    A = deque(A)
    k = A.pop()
    for _ in range(p-1):
        t = A.popleft()
        print(k, t)
        k -= t
    t = A.popleft()
    print(t, k)
    t -= k
    for a in A:
        print(t, a)
        t -= a
