from collections import deque
N = int(input())
A = sorted(list(map(int,input().split())))
A = deque(A)
C = []
while len(A)>1 and A[-1]<=0:
    a = A.pop()
    b = A.pop()
    C.append((a,b))
    A.append(a-b)
if len(A)==1:
    x = A[0]
else:
    B = deque(list(A)[:-1])
    while B[-1]>0:
        a = B.popleft()
        b = B.pop()
        C.append((a,b))
        B.appendleft(a-b)
    B.append(A[-1])
    while len(B)>1:
        a = B.pop()
        b = B.popleft()
        C.append((a,b))
        B.append(a-b)
    x = B[0]
print(x)
for i in range(N-1):
    print(C[i][0],C[i][1]) from collections import deque N = int(input()) N int(input()) int input() input A = sorted(list(map(int,input().split()))) A sorted(list(map(int,input().split()))) sorted list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split A = deque(A) A deque(A) deque A C = [] C [] while len(A)>1 and A[-1]<=0:
    a = A.pop()
    b = A.pop()
    C.append((a,b))
    A.append(a-b) len(A)>1 and A[-1]<=0 len(A)>1 len(A) len A 1 A[-1]<=0 A[-1] A -1 0 a = A.pop() a A.pop() A.pop A pop b = A.pop() b A.pop() A.pop A pop C.append((a,b)) C.append C append (a,b) a b A.append(a-b) A.append A append a-b a b if len(A)==1:
    x = A[0]
else:
    B = deque(list(A)[:-1])
    while B[-1]>0:
        a = B.popleft()
        b = B.pop()
        C.append((a,b))
        B.appendleft(a-b)
    B.append(A[-1])
    while len(B)>1:
        a = B.pop()
        b = B.popleft()
        C.append((a,b))
        B.append(a-b)
    x = B[0] len(A)==1 len(A) len A 1 x = A[0] x A[0] A 0 B = deque(list(A)[:-1]) B deque(list(A)[:-1]) deque list(A)[:-1] (A) list A :-1 -1 while B[-1]>0:
        a = B.popleft()
        b = B.pop()
        C.append((a,b))
        B.appendleft(a-b)
     B[-1]>0 B[-1] B -1 0 a = B.popleft() a B.popleft() B.popleft B popleft b = B.pop() b B.pop() B.pop B pop C.append((a,b)) C.append C append (a,b) a b B.appendleft(a-b) B.appendleft B appendleft a-b a b B.append(A[-1]) B.append B append A[-1] A -1 while len(B)>1:
        a = B.pop()
        b = B.popleft()
        C.append((a,b))
        B.append(a-b)
     len(B)>1 len(B) len B 1 a = B.pop() a B.pop() B.pop B pop b = B.popleft() b B.popleft() B.popleft B popleft C.append((a,b)) C.append C append (a,b) a b B.append(a-b) B.append B append a-b a b x = B[0] x B[0] B 0 print(x) print x for i in range(N-1):
    print(C[i][0],C[i][1]) i range(N-1) range N-1 N 1 print(C[i][0],C[i][1]) print C[i][0] [i] C i 0 C[i][1] [i] C i 1 a = B.pop() B.pop() a A = deque(A) deque(A) A N = int(input()) int(input()) N A = sorted(list(map(int,input().split()))) sorted(list(map(int,input().split()))) A C = [] [] C b = B.pop() B.pop() b a = A.pop() A.pop() a B = deque(list(A)[:-1]) deque(list(A)[:-1]) B b = B.popleft() B.popleft() b x = A[0] A[0] x a = B.popleft() B.popleft() a x = B[0] B[0] x b = A.pop() A.pop() b
from collections import deque
N = int(input())
A = sorted(list(map(int,input().split())))
A = deque(A)
C = []
while len(A)>1 and A[-1]<=0:
    a = A.pop()
    b = A.pop()
    C.append((a,b))
    A.append(a-b)
if len(A)==1:
    x = A[0]
else:
    B = deque(list(A)[:-1])
    while B[-1]>0:
        a = B.popleft()
        b = B.pop()
        C.append((a,b))
        B.appendleft(a-b)
    B.append(A[-1])
    while len(B)>1:
        a = B.pop()
        b = B.popleft()
        C.append((a,b))
        B.append(a-b)
    x = B[0]
print(x)
for i in range(N-1):
    print(C[i][0],C[i][1])