n=int(input())
a=list(map(int,input().split()))
a.sort()
plus,minus=[],[]
for i in range(n):
    if a[i]>=0:
        plus.append(a[i])
    else:
        minus.append(a[i])
order=[]
if plus and minus:
    if len(plus)>=2:
        for num in plus[:-1]:
            order.append((minus[0],num))
            minus[0]-=num
    for num in minus:
        order.append((plus[-1],num))
        plus[-1]-=num
    print(plus[-1])
else:
    if minus:
        a=a[::-1]
    for i in range(1,n-1):
        order.append((a[0],a[i]))
        a[0]-=a[i]
    if minus:
        a=a[::-1]
    order.append((a[-1],a[0]))
    a[-1]-=a[0]
    print(a[-1])
for x,y in order:
    print(x,y) 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 plus,minus=[],[] plus [] minus [] for i in range(n):
    if a[i]>=0:
        plus.append(a[i])
    else:
        minus.append(a[i]) i range(n) range n if a[i]>=0:
        plus.append(a[i])
    else:
        minus.append(a[i]) a[i]>=0 a[i] a i 0 plus.append(a[i]) plus.append plus append a[i] a i minus.append(a[i]) minus.append minus append a[i] a i order=[] order [] if plus and minus:
    if len(plus)>=2:
        for num in plus[:-1]:
            order.append((minus[0],num))
            minus[0]-=num
    for num in minus:
        order.append((plus[-1],num))
        plus[-1]-=num
    print(plus[-1])
else:
    if minus:
        a=a[::-1]
    for i in range(1,n-1):
        order.append((a[0],a[i]))
        a[0]-=a[i]
    if minus:
        a=a[::-1]
    order.append((a[-1],a[0]))
    a[-1]-=a[0]
    print(a[-1]) plus and minus plus minus if len(plus)>=2:
        for num in plus[:-1]:
            order.append((minus[0],num))
            minus[0]-=num
     len(plus)>=2 len(plus) len plus 2 for num in plus[:-1]:
            order.append((minus[0],num))
            minus[0]-=num
     num plus[:-1] plus :-1 -1 order.append((minus[0],num)) order.append order append (minus[0],num) minus[0] minus 0 num minus[0]-=num minus[0] minus 0 num for num in minus:
        order.append((plus[-1],num))
        plus[-1]-=num
     num minus order.append((plus[-1],num)) order.append order append (plus[-1],num) plus[-1] plus -1 num plus[-1]-=num plus[-1] plus -1 num print(plus[-1]) print plus[-1] plus -1 if minus:
        a=a[::-1]
     minus a=a[::-1] a a[::-1] a ::-1 -1 for i in range(1,n-1):
        order.append((a[0],a[i]))
        a[0]-=a[i]
     i range(1,n-1) range 1 n-1 n 1 order.append((a[0],a[i])) order.append order append (a[0],a[i]) a[0] a 0 a[i] a i a[0]-=a[i] a[0] a 0 a[i] a i if minus:
        a=a[::-1]
     minus a=a[::-1] a a[::-1] a ::-1 -1 order.append((a[-1],a[0])) order.append order append (a[-1],a[0]) a[-1] a -1 a[0] a 0 a[-1]-=a[0] a[-1] a -1 a[0] a 0 print(a[-1]) print a[-1] a -1 for x,y in order:
    print(x,y) x y order print(x,y) print x y plus,minus=[],[] [] plus a=a[::-1] a[::-1] a minus=[],[] [] minus order=[] [] order n=int(input()) int(input()) n a=list(map(int,input().split())) list(map(int,input().split())) a a=a[::-1] a[::-1] a
n=int(input())
a=list(map(int,input().split()))
a.sort()
plus,minus=[],[]
for i in range(n):
    if a[i]>=0:
        plus.append(a[i])
    else:
        minus.append(a[i])
order=[]
if plus and minus:
    if len(plus)>=2:
        for num in plus[:-1]:
            order.append((minus[0],num))
            minus[0]-=num
    for num in minus:
        order.append((plus[-1],num))
        plus[-1]-=num
    print(plus[-1])
else:
    if minus:
        a=a[::-1]
    for i in range(1,n-1):
        order.append((a[0],a[i]))
        a[0]-=a[i]
    if minus:
        a=a[::-1]
    order.append((a[-1],a[0]))
    a[-1]-=a[0]
    print(a[-1])
for x,y in order:
    print(x,y)