n=int(input())
p,m=[],[]
z=0
for i in list(map(int,input().split())):
    if i<0:m.append(i)
    elif i==0:
        z+=1
    else:p.append(i)
if p and m:
    print(sum(p)-sum(m))
    if z:
        for h in range(z-1):
            print("0 0")
        now=0
    else:now=p.pop()
    for j in m[1:]:
        print(now,j)
        now-=j
    if p:
        print(m[0],now)
        now=-now+m[0]
        for j in p[1:]:
            print(now,j)
            now-=j
        print(p[0],now)
    else:
        print(now,m[0])
elif p:
    if z:
        print(sum(p))
        for h in  range(z-1):
            print("0 0")
        now=0
        f=p.pop()
        for i in p:
            print(now,i)
            now-=i
        print(f,now)
    else:
        print(sum(p)-2*min(p))
        p.sort()
        now=p[0]
        k=p.pop()
        for j in p[1:]:
            print(now,j)
            now-=j
        print(k,now)
else:
    if z:
        print(-sum(m))
        for h in  range(z-1):
            print("0 0")
        now=0
    else:
        m.sort()
        print(-sum(m)+2*max(m))
        now=m.pop()
    for i in m:
        print(now,i)
        now-=i
 n=int(input()) n int(input()) int input() input p,m=[],[] p [] m [] z=0 z 0 for i in list(map(int,input().split())):
    if i<0:m.append(i)
    elif i==0:
        z+=1
    else:p.append(i) i list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split if i<0:m.append(i)
    elif i==0:
        z+=1
    else:p.append(i) i<0 i 0 elif i==0:
        z+=1
     i==0 i 0 z+=1 z 1 if p and m:
    print(sum(p)-sum(m))
    if z:
        for h in range(z-1):
            print("0 0")
        now=0
    else:now=p.pop()
    for j in m[1:]:
        print(now,j)
        now-=j
    if p:
        print(m[0],now)
        now=-now+m[0]
        for j in p[1:]:
            print(now,j)
            now-=j
        print(p[0],now)
    else:
        print(now,m[0])
elif p:
    if z:
        print(sum(p))
        for h in  range(z-1):
            print("0 0")
        now=0
        f=p.pop()
        for i in p:
            print(now,i)
            now-=i
        print(f,now)
    else:
        print(sum(p)-2*min(p))
        p.sort()
        now=p[0]
        k=p.pop()
        for j in p[1:]:
            print(now,j)
            now-=j
        print(k,now)
else:
    if z:
        print(-sum(m))
        for h in  range(z-1):
            print("0 0")
        now=0
    else:
        m.sort()
        print(-sum(m)+2*max(m))
        now=m.pop()
    for i in m:
        print(now,i)
        now-=i p and m p m print(sum(p)-sum(m)) print sum(p)-sum(m) sum(p) sum p sum(m) sum m if z:
        for h in range(z-1):
            print("0 0")
        now=0
    else:now=p.pop()
     z for h in range(z-1):
            print("0 0")
         h range(z-1) range z-1 z 1 print("0 0") print "0 0" now=0 now 0 for j in m[1:]:
        print(now,j)
        now-=j
     j m[1:] m 1: 1 print(now,j) print now j now-=j now j if p:
        print(m[0],now)
        now=-now+m[0]
        for j in p[1:]:
            print(now,j)
            now-=j
        print(p[0],now)
    else:
        print(now,m[0]) p print(m[0],now) print m[0] m 0 now now=-now+m[0] now -now+m[0] -now now m[0] m 0 for j in p[1:]:
            print(now,j)
            now-=j
         j p[1:] p 1: 1 print(now,j) print now j now-=j now j print(p[0],now) print p[0] p 0 now print(now,m[0]) print now m[0] m 0 elif p:
    if z:
        print(sum(p))
        for h in  range(z-1):
            print("0 0")
        now=0
        f=p.pop()
        for i in p:
            print(now,i)
            now-=i
        print(f,now)
    else:
        print(sum(p)-2*min(p))
        p.sort()
        now=p[0]
        k=p.pop()
        for j in p[1:]:
            print(now,j)
            now-=j
        print(k,now) p if z:
        print(sum(p))
        for h in  range(z-1):
            print("0 0")
        now=0
        f=p.pop()
        for i in p:
            print(now,i)
            now-=i
        print(f,now)
    else:
        print(sum(p)-2*min(p))
        p.sort()
        now=p[0]
        k=p.pop()
        for j in p[1:]:
            print(now,j)
            now-=j
        print(k,now) z print(sum(p)) print sum(p) sum p for h in  range(z-1):
            print("0 0")
         h range(z-1) range z-1 z 1 print("0 0") print "0 0" now=0 now 0 f=p.pop() f p.pop() p.pop p pop for i in p:
            print(now,i)
            now-=i
         i p print(now,i) print now i now-=i now i print(f,now) print f now print(sum(p)-2*min(p)) print sum(p)-2*min(p) sum(p) sum p 2*min(p) 2 min(p) min p p.sort() p.sort p sort now=p[0] now p[0] p 0 k=p.pop() k p.pop() p.pop p pop for j in p[1:]:
            print(now,j)
            now-=j
         j p[1:] p 1: 1 print(now,j) print now j now-=j now j print(k,now) print k now if z:
        print(-sum(m))
        for h in  range(z-1):
            print("0 0")
        now=0
    else:
        m.sort()
        print(-sum(m)+2*max(m))
        now=m.pop()
     z print(-sum(m)) print -sum(m) sum(m) sum m for h in  range(z-1):
            print("0 0")
         h range(z-1) range z-1 z 1 print("0 0") print "0 0" now=0 now 0 m.sort() m.sort m sort print(-sum(m)+2*max(m)) print -sum(m)+2*max(m) -sum(m) sum(m) sum m 2*max(m) 2 max(m) max m now=m.pop() now m.pop() m.pop m pop for i in m:
        print(now,i)
        now-=i i m print(now,i) print now i now-=i now i now=0 0 now z+=1 1 z k=p.pop() p.pop() k now=-now+m[0] -now+m[0] now z=0 0 z now-=i i now now=m.pop() m.pop() now now-=j j now n=int(input()) int(input()) n now=0 0 now f=p.pop() p.pop() f now=0 0 now now-=j j now now-=j j now p,m=[],[] [] p now-=i i now now=p[0] p[0] now m=[],[] [] m
n=int(input())
p,m=[],[]
z=0
for i in list(map(int,input().split())):
    if i<0:m.append(i)
    elif i==0:
        z+=1
    else:p.append(i)
if p and m:
    print(sum(p)-sum(m))
    if z:
        for h in range(z-1):
            print("0 0")
        now=0
    else:now=p.pop()
    for j in m[1:]:
        print(now,j)
        now-=j
    if p:
        print(m[0],now)
        now=-now+m[0]
        for j in p[1:]:
            print(now,j)
            now-=j
        print(p[0],now)
    else:
        print(now,m[0])
elif p:
    if z:
        print(sum(p))
        for h in  range(z-1):
            print("0 0")
        now=0
        f=p.pop()
        for i in p:
            print(now,i)
            now-=i
        print(f,now)
    else:
        print(sum(p)-2*min(p))
        p.sort()
        now=p[0]
        k=p.pop()
        for j in p[1:]:
            print(now,j)
            now-=j
        print(k,now)
else:
    if z:
        print(-sum(m))
        for h in  range(z-1):
            print("0 0")
        now=0
    else:
        m.sort()
        print(-sum(m)+2*max(m))
        now=m.pop()
    for i in m:
        print(now,i)
        now-=i

