n = int(input())
mi = []
pl = []

l = list(map(int,input().split()))
for i in l:
    if i >= 0:
        pl.append(i)
    else:
        mi.append(i)
pl.sort()
mi.sort()
if n == 2:
    print(max(l)-min(l))
    print(max(l),min(l))
    exit()

if pl and mi:
    ans = []
    np = pl[-1]
    for i in range(1,len(mi)):
        ans.append([np,mi[i]])
        np -= mi[i]
    nm = mi[0]
    for i in range(len(pl)-1):
        ans.append([nm,pl[i]])
        nm -= pl[i]
    ans.append([np,nm])
    print(np-nm)
    for i in ans:
        print(*i)
elif pl:
    ans = []
    ans.append([pl[0],pl[1]])
    nm = pl[0]-pl[1]
    for i in range(2,len(pl)-1):
        ans.append([nm,pl[i]])
        nm -= pl[i]
    ans.append([pl[-1],nm])
    print(pl[-1]-nm)
    for i in ans:
        print(*i)
else:
    ans = []
    ans.append([mi[-1],mi[-2]])
    np = mi[-1]-mi[-2]
    for i in range(1,len(mi)-2):
        ans.append([np,mi[i]])
        np -= mi[i]
    ans.append([np,mi[0]])
    print(np-mi[0])
    for i in ans:
        print(*i) n = int(input()) n int(input()) int input() input mi = [] mi [] pl = [] pl [] l = list(map(int,input().split())) l list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for i in l:
    if i >= 0:
        pl.append(i)
    else:
        mi.append(i) i l if i >= 0:
        pl.append(i)
    else:
        mi.append(i) i >= 0 i 0 pl.append(i) pl.append pl append i mi.append(i) mi.append mi append i pl.sort() pl.sort pl sort mi.sort() mi.sort mi sort if n == 2:
    print(max(l)-min(l))
    print(max(l),min(l))
    exit() n == 2 n 2 print(max(l)-min(l)) print max(l)-min(l) max(l) max l min(l) min l print(max(l),min(l)) print max(l) max l min(l) min l exit() exit if pl and mi:
    ans = []
    np = pl[-1]
    for i in range(1,len(mi)):
        ans.append([np,mi[i]])
        np -= mi[i]
    nm = mi[0]
    for i in range(len(pl)-1):
        ans.append([nm,pl[i]])
        nm -= pl[i]
    ans.append([np,nm])
    print(np-nm)
    for i in ans:
        print(*i)
elif pl:
    ans = []
    ans.append([pl[0],pl[1]])
    nm = pl[0]-pl[1]
    for i in range(2,len(pl)-1):
        ans.append([nm,pl[i]])
        nm -= pl[i]
    ans.append([pl[-1],nm])
    print(pl[-1]-nm)
    for i in ans:
        print(*i)
else:
    ans = []
    ans.append([mi[-1],mi[-2]])
    np = mi[-1]-mi[-2]
    for i in range(1,len(mi)-2):
        ans.append([np,mi[i]])
        np -= mi[i]
    ans.append([np,mi[0]])
    print(np-mi[0])
    for i in ans:
        print(*i) pl and mi pl mi ans = [] ans [] np = pl[-1] np pl[-1] pl -1 for i in range(1,len(mi)):
        ans.append([np,mi[i]])
        np -= mi[i]
     i range(1,len(mi)) range 1 len(mi) len mi ans.append([np,mi[i]]) ans.append ans append [np,mi[i]] np mi[i] mi i np -= mi[i] np mi[i] mi i nm = mi[0] nm mi[0] mi 0 for i in range(len(pl)-1):
        ans.append([nm,pl[i]])
        nm -= pl[i]
     i range(len(pl)-1) range len(pl)-1 len(pl) len pl 1 ans.append([nm,pl[i]]) ans.append ans append [nm,pl[i]] nm pl[i] pl i nm -= pl[i] nm pl[i] pl i ans.append([np,nm]) ans.append ans append [np,nm] np nm print(np-nm) print np-nm np nm for i in ans:
        print(*i) i ans print(*i) print *i i elif pl:
    ans = []
    ans.append([pl[0],pl[1]])
    nm = pl[0]-pl[1]
    for i in range(2,len(pl)-1):
        ans.append([nm,pl[i]])
        nm -= pl[i]
    ans.append([pl[-1],nm])
    print(pl[-1]-nm)
    for i in ans:
        print(*i) pl ans = [] ans [] ans.append([pl[0],pl[1]]) ans.append ans append [pl[0],pl[1]] pl[0] pl 0 pl[1] pl 1 nm = pl[0]-pl[1] nm pl[0]-pl[1] pl[0] pl 0 pl[1] pl 1 for i in range(2,len(pl)-1):
        ans.append([nm,pl[i]])
        nm -= pl[i]
     i range(2,len(pl)-1) range 2 len(pl)-1 len(pl) len pl 1 ans.append([nm,pl[i]]) ans.append ans append [nm,pl[i]] nm pl[i] pl i nm -= pl[i] nm pl[i] pl i ans.append([pl[-1],nm]) ans.append ans append [pl[-1],nm] pl[-1] pl -1 nm print(pl[-1]-nm) print pl[-1]-nm pl[-1] pl -1 nm for i in ans:
        print(*i) i ans print(*i) print *i i ans = [] ans [] ans.append([mi[-1],mi[-2]]) ans.append ans append [mi[-1],mi[-2]] mi[-1] mi -1 mi[-2] mi -2 np = mi[-1]-mi[-2] np mi[-1]-mi[-2] mi[-1] mi -1 mi[-2] mi -2 for i in range(1,len(mi)-2):
        ans.append([np,mi[i]])
        np -= mi[i]
     i range(1,len(mi)-2) range 1 len(mi)-2 len(mi) len mi 2 ans.append([np,mi[i]]) ans.append ans append [np,mi[i]] np mi[i] mi i np -= mi[i] np mi[i] mi i ans.append([np,mi[0]]) ans.append ans append [np,mi[0]] np mi[0] mi 0 print(np-mi[0]) print np-mi[0] np mi[0] mi 0 for i in ans:
        print(*i) i ans print(*i) print *i i nm = pl[0]-pl[1] pl[0]-pl[1] nm np -= mi[i] mi[i] np nm = mi[0] mi[0] nm ans = [] [] ans nm -= pl[i] pl[i] nm np = mi[-1]-mi[-2] mi[-1]-mi[-2] np l = list(map(int,input().split())) list(map(int,input().split())) l ans = [] [] ans mi = [] [] mi nm -= pl[i] pl[i] nm pl = [] [] pl ans = [] [] ans np -= mi[i] mi[i] np np = pl[-1] pl[-1] np n = int(input()) int(input()) n
n = int(input())
mi = []
pl = []

l = list(map(int,input().split()))
for i in l:
    if i >= 0:
        pl.append(i)
    else:
        mi.append(i)
pl.sort()
mi.sort()
if n == 2:
    print(max(l)-min(l))
    print(max(l),min(l))
    exit()

if pl and mi:
    ans = []
    np = pl[-1]
    for i in range(1,len(mi)):
        ans.append([np,mi[i]])
        np -= mi[i]
    nm = mi[0]
    for i in range(len(pl)-1):
        ans.append([nm,pl[i]])
        nm -= pl[i]
    ans.append([np,nm])
    print(np-nm)
    for i in ans:
        print(*i)
elif pl:
    ans = []
    ans.append([pl[0],pl[1]])
    nm = pl[0]-pl[1]
    for i in range(2,len(pl)-1):
        ans.append([nm,pl[i]])
        nm -= pl[i]
    ans.append([pl[-1],nm])
    print(pl[-1]-nm)
    for i in ans:
        print(*i)
else:
    ans = []
    ans.append([mi[-1],mi[-2]])
    np = mi[-1]-mi[-2]
    for i in range(1,len(mi)-2):
        ans.append([np,mi[i]])
        np -= mi[i]
    ans.append([np,mi[0]])
    print(np-mi[0])
    for i in ans:
        print(*i)
