import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
pos, neg, zero = [], [], []

for Ai in A:
    if Ai>0:
        pos.append(Ai)
    elif Ai<0:
        neg.append(Ai)
    else:
        zero.append(0)

if len(neg)==0:
    neg += zero
else:
    pos += zero
    
ope = []

if len(pos)>0 and len(neg)>0:
    now1 = pos[0]
    
    for i in range(1, len(neg)):
        ope.append((now1, neg[i]))
        now1 -= neg[i]
    
    now2 = neg[0]
    
    for i in range(1, len(pos)):
        ope.append((now2, pos[i]))
        now2 -= pos[i]
    
    ope.append((now1, now2))
    M = now1-now2
elif len(pos)==0:
    neg.sort(reverse=True)
    now = neg[0]
    
    for i in range(1, len(neg)):
        ope.append((now, neg[i]))
        now -= neg[i]
    
    M = now
else:
    pos.sort()
    now = pos[0]
    
    for i in range(1, len(pos)-1):
        ope.append((now, pos[i]))
        now -= pos[i]
    
    ope.append((pos[-1], now))
    M = pos[-1]-now

print(M)

for x, y in ope:
    print(x, y) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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 pos, neg, zero = [], [], [] pos [] neg [] zero [] for Ai in A:
    if Ai>0:
        pos.append(Ai)
    elif Ai<0:
        neg.append(Ai)
    else:
        zero.append(0) Ai A if Ai>0:
        pos.append(Ai)
    elif Ai<0:
        neg.append(Ai)
    else:
        zero.append(0) Ai>0 Ai 0 pos.append(Ai) pos.append pos append Ai elif Ai<0:
        neg.append(Ai)
     Ai<0 Ai 0 neg.append(Ai) neg.append neg append Ai zero.append(0) zero.append zero append 0 if len(neg)==0:
    neg += zero
else:
    pos += zero
     len(neg)==0 len(neg) len neg 0 neg += zero neg zero pos += zero pos zero ope = [] ope [] if len(pos)>0 and len(neg)>0:
    now1 = pos[0]
    
    for i in range(1, len(neg)):
        ope.append((now1, neg[i]))
        now1 -= neg[i]
    
    now2 = neg[0]
    
    for i in range(1, len(pos)):
        ope.append((now2, pos[i]))
        now2 -= pos[i]
    
    ope.append((now1, now2))
    M = now1-now2
elif len(pos)==0:
    neg.sort(reverse=True)
    now = neg[0]
    
    for i in range(1, len(neg)):
        ope.append((now, neg[i]))
        now -= neg[i]
    
    M = now
else:
    pos.sort()
    now = pos[0]
    
    for i in range(1, len(pos)-1):
        ope.append((now, pos[i]))
        now -= pos[i]
    
    ope.append((pos[-1], now))
    M = pos[-1]-now len(pos)>0 and len(neg)>0 len(pos)>0 len(pos) len pos 0 len(neg)>0 len(neg) len neg 0 now1 = pos[0] now1 pos[0] pos 0 for i in range(1, len(neg)):
        ope.append((now1, neg[i]))
        now1 -= neg[i]
    
     i range(1, len(neg)) range 1 len(neg) len neg ope.append((now1, neg[i])) ope.append ope append (now1, neg[i]) now1 neg[i] neg i now1 -= neg[i] now1 neg[i] neg i now2 = neg[0] now2 neg[0] neg 0 for i in range(1, len(pos)):
        ope.append((now2, pos[i]))
        now2 -= pos[i]
    
     i range(1, len(pos)) range 1 len(pos) len pos ope.append((now2, pos[i])) ope.append ope append (now2, pos[i]) now2 pos[i] pos i now2 -= pos[i] now2 pos[i] pos i ope.append((now1, now2)) ope.append ope append (now1, now2) now1 now2 M = now1-now2 M now1-now2 now1 now2 elif len(pos)==0:
    neg.sort(reverse=True)
    now = neg[0]
    
    for i in range(1, len(neg)):
        ope.append((now, neg[i]))
        now -= neg[i]
    
    M = now len(pos)==0 len(pos) len pos 0 neg.sort(reverse=True) neg.sort neg sort reverse=True reverse True now = neg[0] now neg[0] neg 0 for i in range(1, len(neg)):
        ope.append((now, neg[i]))
        now -= neg[i]
    
     i range(1, len(neg)) range 1 len(neg) len neg ope.append((now, neg[i])) ope.append ope append (now, neg[i]) now neg[i] neg i now -= neg[i] now neg[i] neg i M = now M now pos.sort() pos.sort pos sort now = pos[0] now pos[0] pos 0 for i in range(1, len(pos)-1):
        ope.append((now, pos[i]))
        now -= pos[i]
    
     i range(1, len(pos)-1) range 1 len(pos)-1 len(pos) len pos 1 ope.append((now, pos[i])) ope.append ope append (now, pos[i]) now pos[i] pos i now -= pos[i] now pos[i] pos i ope.append((pos[-1], now)) ope.append ope append (pos[-1], now) pos[-1] pos -1 now M = pos[-1]-now M pos[-1]-now pos[-1] pos -1 now print(M) print M for x, y in ope:
    print(x, y) x y ope print(x, y) print x y zero = [], [], [] [] zero now1 -= neg[i] neg[i] now1 M = now now M A = list(map(int, input().split())) list(map(int, input().split())) A pos += zero zero pos M = now1-now2 now1-now2 M ope = [] [] ope N = int(input()) int(input()) N now = pos[0] pos[0] now now -= pos[i] pos[i] now M = pos[-1]-now pos[-1]-now M now = neg[0] neg[0] now now -= neg[i] neg[i] now neg, zero = [], [], [] [] neg now2 = neg[0] neg[0] now2 neg += zero zero neg input = sys.stdin.readline sys.stdin.readline input pos, neg, zero = [], [], [] [] pos now2 -= pos[i] pos[i] now2 now1 = pos[0] pos[0] now1
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
pos, neg, zero = [], [], []

for Ai in A:
    if Ai>0:
        pos.append(Ai)
    elif Ai<0:
        neg.append(Ai)
    else:
        zero.append(0)

if len(neg)==0:
    neg += zero
else:
    pos += zero
    
ope = []

if len(pos)>0 and len(neg)>0:
    now1 = pos[0]
    
    for i in range(1, len(neg)):
        ope.append((now1, neg[i]))
        now1 -= neg[i]
    
    now2 = neg[0]
    
    for i in range(1, len(pos)):
        ope.append((now2, pos[i]))
        now2 -= pos[i]
    
    ope.append((now1, now2))
    M = now1-now2
elif len(pos)==0:
    neg.sort(reverse=True)
    now = neg[0]
    
    for i in range(1, len(neg)):
        ope.append((now, neg[i]))
        now -= neg[i]
    
    M = now
else:
    pos.sort()
    now = pos[0]
    
    for i in range(1, len(pos)-1):
        ope.append((now, pos[i]))
        now -= pos[i]
    
    ope.append((pos[-1], now))
    M = pos[-1]-now

print(M)

for x, y in ope:
    print(x, y)