from collections import deque

N = int(input())
A = list(map(int, input().split()))
A.sort()

# A[cut-1] < 0 and A[cut] >= 0
cut = 0
while cut < N and A[cut] < 0:
    cut += 1

if cut == 0:
    M = sum(A[1:]) - A[0]
    print(M)
    pair = [A[0], A[N-1]]
    for i in range(N-2):
        print(' '.join(map(str, pair)))
        pair = [pair[0] - pair[1], A[N-i-2]]
    pair.reverse()
    print(' '.join(map(str, pair)))

elif cut == N:
    M = A[-1] - sum(A[:N-1])
    print(M)
    pair = [A[N-1], A[0]]
    for i in range(N-2):
        print(' '.join(map(str, pair)))
        pair = [pair[0] - pair[1], A[i+1]]
    print(' '.join(map(str, pair)))

else:
    M = sum(A[cut:]) - sum(A[:cut])
    print(M)

    B = deque(A[cut:]) # Aの正の部分
    C = deque(A[:cut]) # Aの負の部分

    while len(B) != 1:
        pair = [C[-1], B[-1]]
        print(' '.join(map(str, pair)))
        b = B.pop()
        C[-1] = C[-1] - b
    
    b = B.pop()

    while len(C) != 0:
        pair = [b, C[0]]
        print(' '.join(map(str, pair)))
        c = C.popleft()
        b = b - c 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() A.sort A sort cut = 0 cut 0 while cut < N and A[cut] < 0:
    cut += 1 cut < N and A[cut] < 0 cut < N cut N A[cut] < 0 A[cut] A cut 0 cut += 1 cut 1 if cut == 0:
    M = sum(A[1:]) - A[0]
    print(M)
    pair = [A[0], A[N-1]]
    for i in range(N-2):
        print(' '.join(map(str, pair)))
        pair = [pair[0] - pair[1], A[N-i-2]]
    pair.reverse()
    print(' '.join(map(str, pair)))

elif cut == N:
    M = A[-1] - sum(A[:N-1])
    print(M)
    pair = [A[N-1], A[0]]
    for i in range(N-2):
        print(' '.join(map(str, pair)))
        pair = [pair[0] - pair[1], A[i+1]]
    print(' '.join(map(str, pair)))

else:
    M = sum(A[cut:]) - sum(A[:cut])
    print(M)

    B = deque(A[cut:]) # Aの正の部分
    C = deque(A[:cut]) # Aの負の部分

    while len(B) != 1:
        pair = [C[-1], B[-1]]
        print(' '.join(map(str, pair)))
        b = B.pop()
        C[-1] = C[-1] - b
    
    b = B.pop()

    while len(C) != 0:
        pair = [b, C[0]]
        print(' '.join(map(str, pair)))
        c = C.popleft()
        b = b - c cut == 0 cut 0 M = sum(A[1:]) - A[0] M sum(A[1:]) - A[0] sum(A[1:]) sum A[1:] A 1: 1 A[0] A 0 print(M) print M pair = [A[0], A[N-1]] pair [A[0], A[N-1]] A[0] A 0 A[N-1] A N-1 N 1 for i in range(N-2):
        print(' '.join(map(str, pair)))
        pair = [pair[0] - pair[1], A[N-i-2]]
     i range(N-2) range N-2 N 2 print(' '.join(map(str, pair))) print ' '.join(map(str, pair)) ' '.join ' ' join map(str, pair) map str pair pair = [pair[0] - pair[1], A[N-i-2]] pair [pair[0] - pair[1], A[N-i-2]] pair[0] - pair[1] pair[0] pair 0 pair[1] pair 1 A[N-i-2] A N-i-2 N-i N i 2 pair.reverse() pair.reverse pair reverse print(' '.join(map(str, pair))) print ' '.join(map(str, pair)) ' '.join ' ' join map(str, pair) map str pair elif cut == N:
    M = A[-1] - sum(A[:N-1])
    print(M)
    pair = [A[N-1], A[0]]
    for i in range(N-2):
        print(' '.join(map(str, pair)))
        pair = [pair[0] - pair[1], A[i+1]]
    print(' '.join(map(str, pair))) cut == N cut N M = A[-1] - sum(A[:N-1]) M A[-1] - sum(A[:N-1]) A[-1] A -1 sum(A[:N-1]) sum A[:N-1] A :N-1 N-1 N 1 print(M) print M pair = [A[N-1], A[0]] pair [A[N-1], A[0]] A[N-1] A N-1 N 1 A[0] A 0 for i in range(N-2):
        print(' '.join(map(str, pair)))
        pair = [pair[0] - pair[1], A[i+1]]
     i range(N-2) range N-2 N 2 print(' '.join(map(str, pair))) print ' '.join(map(str, pair)) ' '.join ' ' join map(str, pair) map str pair pair = [pair[0] - pair[1], A[i+1]] pair [pair[0] - pair[1], A[i+1]] pair[0] - pair[1] pair[0] pair 0 pair[1] pair 1 A[i+1] A i+1 i 1 print(' '.join(map(str, pair))) print ' '.join(map(str, pair)) ' '.join ' ' join map(str, pair) map str pair M = sum(A[cut:]) - sum(A[:cut]) M sum(A[cut:]) - sum(A[:cut]) sum(A[cut:]) sum A[cut:] A cut: cut sum(A[:cut]) sum A[:cut] A :cut cut print(M) print M B = deque(A[cut:]) B deque(A[cut:]) deque A[cut:] A cut: cut C = deque(A[:cut]) C deque(A[:cut]) deque A[:cut] A :cut cut while len(B) != 1:
        pair = [C[-1], B[-1]]
        print(' '.join(map(str, pair)))
        b = B.pop()
        C[-1] = C[-1] - b
    
     len(B) != 1 len(B) len B 1 pair = [C[-1], B[-1]] pair [C[-1], B[-1]] C[-1] C -1 B[-1] B -1 print(' '.join(map(str, pair))) print ' '.join(map(str, pair)) ' '.join ' ' join map(str, pair) map str pair b = B.pop() b B.pop() B.pop B pop C[-1] = C[-1] - b C[-1] C -1 C[-1] - b C[-1] C -1 b b = B.pop() b B.pop() B.pop B pop while len(C) != 0:
        pair = [b, C[0]]
        print(' '.join(map(str, pair)))
        c = C.popleft()
        b = b - c len(C) != 0 len(C) len C 0 pair = [b, C[0]] pair [b, C[0]] b C[0] C 0 print(' '.join(map(str, pair))) print ' '.join(map(str, pair)) ' '.join ' ' join map(str, pair) map str pair c = C.popleft() c C.popleft() C.popleft C popleft b = b - c b b - c b c A = list(map(int, input().split())) list(map(int, input().split())) A N = int(input()) int(input()) N cut += 1 1 cut C = deque(A[:cut]) deque(A[:cut]) C cut = 0 0 cut M = sum(A[1:]) - A[0] sum(A[1:]) - A[0] M M = sum(A[cut:]) - sum(A[:cut]) sum(A[cut:]) - sum(A[:cut]) M pair = [C[-1], B[-1]] [C[-1], B[-1]] pair pair = [pair[0] - pair[1], A[N-i-2]] [pair[0] - pair[1], A[N-i-2]] pair c = C.popleft() C.popleft() c b = b - c b - c b pair = [A[N-1], A[0]] [A[N-1], A[0]] pair b = B.pop() B.pop() b b = B.pop() B.pop() b pair = [pair[0] - pair[1], A[i+1]] [pair[0] - pair[1], A[i+1]] pair pair = [b, C[0]] [b, C[0]] pair B = deque(A[cut:]) deque(A[cut:]) B pair = [A[0], A[N-1]] [A[0], A[N-1]] pair M = A[-1] - sum(A[:N-1]) A[-1] - sum(A[:N-1]) M
from collections import deque

N = int(input())
A = list(map(int, input().split()))
A.sort()

# A[cut-1] < 0 and A[cut] >= 0
cut = 0
while cut < N and A[cut] < 0:
    cut += 1

if cut == 0:
    M = sum(A[1:]) - A[0]
    print(M)
    pair = [A[0], A[N-1]]
    for i in range(N-2):
        print(' '.join(map(str, pair)))
        pair = [pair[0] - pair[1], A[N-i-2]]
    pair.reverse()
    print(' '.join(map(str, pair)))

elif cut == N:
    M = A[-1] - sum(A[:N-1])
    print(M)
    pair = [A[N-1], A[0]]
    for i in range(N-2):
        print(' '.join(map(str, pair)))
        pair = [pair[0] - pair[1], A[i+1]]
    print(' '.join(map(str, pair)))

else:
    M = sum(A[cut:]) - sum(A[:cut])
    print(M)

    B = deque(A[cut:]) # Aの正の部分
    C = deque(A[:cut]) # Aの負の部分

    while len(B) != 1:
        pair = [C[-1], B[-1]]
        print(' '.join(map(str, pair)))
        b = B.pop()
        C[-1] = C[-1] - b
    
    b = B.pop()

    while len(C) != 0:
        pair = [b, C[0]]
        print(' '.join(map(str, pair)))
        c = C.popleft()
        b = b - c