from heapq import heappop,heappush
n = int(input())
A = sorted(list(map(int,input().split())))
P = []
M = []
if n == 2:
    print(A[1]-A[0])
    print(A[1],A[0])
    exit()
def move():
    while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
    while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm)
for a in A:
    if a>=0:
        P.append(a)
    else:
        M.append(a)

if A[-1]>=0 and A[0]<0:
    print(sum(abs(a) for a in A))
    while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
    while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm)
elif A[0]>=0:
    print(sum(A)-min(A)*2)
    mm = heappop(P)
    pp = heappop(P)
    print(mm,pp)
    heappush(M,mm-pp)
    while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
    while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm)
else:
    print(sum(abs(a) for a in A)+max(A)*2)
    mm = M[-1]
    pp = M[-2]
    print(mm,pp)
    M = M[:-2]
    heappush(P,mm-pp)
    while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
    while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm) from heapq import heappop,heappush 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 P = [] P [] M = [] M [] if n == 2:
    print(A[1]-A[0])
    print(A[1],A[0])
    exit() n == 2 n 2 print(A[1]-A[0]) print A[1]-A[0] A[1] A 1 A[0] A 0 print(A[1],A[0]) print A[1] A 1 A[0] A 0 exit() exit def move():
    while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
    while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm) move while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
     len(P)!= 1 len(P) len P 1 mm = heappop(M) mm heappop(M) heappop M pp = heappop(P) pp heappop(P) heappop P print(mm,pp) print mm pp heappush(M,mm-pp) heappush M mm-pp mm pp while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm) len(M) != 0 len(M) len M 0 mm = heappop(M) mm heappop(M) heappop M pp = heappop(P) pp heappop(P) heappop P print(pp,mm) print pp mm heappush(P,pp-mm) heappush P pp-mm pp mm for a in A:
    if a>=0:
        P.append(a)
    else:
        M.append(a) a A if a>=0:
        P.append(a)
    else:
        M.append(a) a>=0 a 0 P.append(a) P.append P append a M.append(a) M.append M append a if A[-1]>=0 and A[0]<0:
    print(sum(abs(a) for a in A))
    while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
    while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm)
elif A[0]>=0:
    print(sum(A)-min(A)*2)
    mm = heappop(P)
    pp = heappop(P)
    print(mm,pp)
    heappush(M,mm-pp)
    while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
    while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm)
else:
    print(sum(abs(a) for a in A)+max(A)*2)
    mm = M[-1]
    pp = M[-2]
    print(mm,pp)
    M = M[:-2]
    heappush(P,mm-pp)
    while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
    while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm) A[-1]>=0 and A[0]<0 A[-1]>=0 A[-1] A -1 0 A[0]<0 A[0] A 0 0 print(sum(abs(a) for a in A)) print sum(abs(a) for a in A) sum abs(a) abs a while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
     len(P)!= 1 len(P) len P 1 mm = heappop(M) mm heappop(M) heappop M pp = heappop(P) pp heappop(P) heappop P print(mm,pp) print mm pp heappush(M,mm-pp) heappush M mm-pp mm pp while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm) len(M) != 0 len(M) len M 0 mm = heappop(M) mm heappop(M) heappop M pp = heappop(P) pp heappop(P) heappop P print(pp,mm) print pp mm heappush(P,pp-mm) heappush P pp-mm pp mm elif A[0]>=0:
    print(sum(A)-min(A)*2)
    mm = heappop(P)
    pp = heappop(P)
    print(mm,pp)
    heappush(M,mm-pp)
    while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
    while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm) A[0]>=0 A[0] A 0 0 print(sum(A)-min(A)*2) print sum(A)-min(A)*2 sum(A) sum A min(A)*2 min(A) min A 2 mm = heappop(P) mm heappop(P) heappop P pp = heappop(P) pp heappop(P) heappop P print(mm,pp) print mm pp heappush(M,mm-pp) heappush M mm-pp mm pp while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
     len(P)!= 1 len(P) len P 1 mm = heappop(M) mm heappop(M) heappop M pp = heappop(P) pp heappop(P) heappop P print(mm,pp) print mm pp heappush(M,mm-pp) heappush M mm-pp mm pp while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm) len(M) != 0 len(M) len M 0 mm = heappop(M) mm heappop(M) heappop M pp = heappop(P) pp heappop(P) heappop P print(pp,mm) print pp mm heappush(P,pp-mm) heappush P pp-mm pp mm print(sum(abs(a) for a in A)+max(A)*2) print sum(abs(a) for a in A)+max(A)*2 sum(abs(a) for a in A) sum abs(a) abs a max(A)*2 max(A) max A 2 mm = M[-1] mm M[-1] M -1 pp = M[-2] pp M[-2] M -2 print(mm,pp) print mm pp M = M[:-2] M M[:-2] M :-2 -2 heappush(P,mm-pp) heappush P mm-pp mm pp while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
     len(P)!= 1 len(P) len P 1 mm = heappop(M) mm heappop(M) heappop M pp = heappop(P) pp heappop(P) heappop P print(mm,pp) print mm pp heappush(M,mm-pp) heappush M mm-pp mm pp while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm) len(M) != 0 len(M) len M 0 mm = heappop(M) mm heappop(M) heappop M pp = heappop(P) pp heappop(P) heappop P print(pp,mm) print pp mm heappush(P,pp-mm) heappush P pp-mm pp mm mm = M[-1] M[-1] mm mm = heappop(M) heappop(M) mm mm = heappop(M) heappop(M) mm pp = heappop(P) heappop(P) pp n = int(input()) int(input()) n pp = M[-2] M[-2] pp pp = heappop(P) heappop(P) pp def move():
    while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
    while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm) def move():
    while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
    while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm) move M = M[:-2] M[:-2] M M = [] [] M mm = heappop(M) heappop(M) mm pp = heappop(P) heappop(P) pp pp = heappop(P) heappop(P) pp mm = heappop(M) heappop(M) mm pp = heappop(P) heappop(P) pp A = sorted(list(map(int,input().split()))) sorted(list(map(int,input().split()))) A mm = heappop(M) heappop(M) mm pp = heappop(P) heappop(P) pp pp = heappop(P) heappop(P) pp P = [] [] P mm = heappop(M) heappop(M) mm mm = heappop(P) heappop(P) mm
from heapq import heappop,heappush
n = int(input())
A = sorted(list(map(int,input().split())))
P = []
M = []
if n == 2:
    print(A[1]-A[0])
    print(A[1],A[0])
    exit()
def move():
    while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
    while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm)
for a in A:
    if a>=0:
        P.append(a)
    else:
        M.append(a)

if A[-1]>=0 and A[0]<0:
    print(sum(abs(a) for a in A))
    while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
    while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm)
elif A[0]>=0:
    print(sum(A)-min(A)*2)
    mm = heappop(P)
    pp = heappop(P)
    print(mm,pp)
    heappush(M,mm-pp)
    while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
    while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm)
else:
    print(sum(abs(a) for a in A)+max(A)*2)
    mm = M[-1]
    pp = M[-2]
    print(mm,pp)
    M = M[:-2]
    heappush(P,mm-pp)
    while len(P)!= 1:
        mm = heappop(M)
        pp = heappop(P)
        print(mm,pp)
        heappush(M,mm-pp)
    while len(M) != 0:
        mm = heappop(M)
        pp = heappop(P)
        print(pp,mm)
        heappush(P,pp-mm)