n=int(input())
a = list(map(int, input().split()))

a.sort()

absum=0
minabs=10**9
for num in a:
        abnum=abs(num)
        absum+=abnum
        if minabs > abnum:
                minabs=abnum

if a[0] <= 0 and a[-1] >=0:
        print(absum)
else:
        print(absum - 2*minabs)
        num1=a.pop(0)
        num2=a.pop(-1)
        if abs(num1) > abs(num2):
                print(num2,num1)
                a.append(num2-num1)
        else:
                print(num1,num2)
                a.append(num1-num2)
a.sort()
#print(a)

now = a[0]
for i in range(len(a)-2,-1,-1):
        if a[i] > 0:
                print(now, a[i])
                now-=a[i]
#print(now)
a[0]=now

now = a[-1]

for i in range(len(a)-1):
        if a[i] >0:
                break
        print(now,a[i])
        now-=a[i] 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 absum=0 absum 0 minabs=10**9 minabs 10**9 10 9 for num in a:
        abnum=abs(num)
        absum+=abnum
        if minabs > abnum:
                minabs=abnum num a abnum=abs(num) abnum abs(num) abs num absum+=abnum absum abnum if minabs > abnum:
                minabs=abnum minabs > abnum minabs abnum minabs=abnum minabs abnum if a[0] <= 0 and a[-1] >=0:
        print(absum)
else:
        print(absum - 2*minabs)
        num1=a.pop(0)
        num2=a.pop(-1)
        if abs(num1) > abs(num2):
                print(num2,num1)
                a.append(num2-num1)
        else:
                print(num1,num2)
                a.append(num1-num2) a[0] <= 0 and a[-1] >=0 a[0] <= 0 a[0] a 0 0 a[-1] >=0 a[-1] a -1 0 print(absum) print absum print(absum - 2*minabs) print absum - 2*minabs absum 2*minabs 2 minabs num1=a.pop(0) num1 a.pop(0) a.pop a pop 0 num2=a.pop(-1) num2 a.pop(-1) a.pop a pop -1 if abs(num1) > abs(num2):
                print(num2,num1)
                a.append(num2-num1)
        else:
                print(num1,num2)
                a.append(num1-num2) abs(num1) > abs(num2) abs(num1) abs num1 abs(num2) abs num2 print(num2,num1) print num2 num1 a.append(num2-num1) a.append a append num2-num1 num2 num1 print(num1,num2) print num1 num2 a.append(num1-num2) a.append a append num1-num2 num1 num2 a.sort() a.sort a sort now = a[0] now a[0] a 0 for i in range(len(a)-2,-1,-1):
        if a[i] > 0:
                print(now, a[i])
                now-=a[i]
#print(now) i range(len(a)-2,-1,-1) range len(a)-2 len(a) len a 2 -1 -1 if a[i] > 0:
                print(now, a[i])
                now-=a[i]
#print(now) a[i] > 0 a[i] a i 0 print(now, a[i]) print now a[i] a i now-=a[i] now a[i] a i a[0]=now a[0] a 0 now now = a[-1] now a[-1] a -1 for i in range(len(a)-1):
        if a[i] >0:
                break
        print(now,a[i])
        now-=a[i] i range(len(a)-1) range len(a)-1 len(a) len a 1 if a[i] >0:
                break
         a[i] >0 a[i] a i 0 break print(now,a[i]) print now a[i] a i now-=a[i] now a[i] a i now = a[0] a[0] now minabs=abnum abnum minabs num2=a.pop(-1) a.pop(-1) num2 n=int(input()) int(input()) n a = list(map(int, input().split())) list(map(int, input().split())) a absum+=abnum abnum absum now-=a[i] a[i] now num1=a.pop(0) a.pop(0) num1 now = a[-1] a[-1] now abnum=abs(num) abs(num) abnum absum=0 0 absum now-=a[i] a[i] now minabs=10**9 10**9 minabs
n=int(input())
a = list(map(int, input().split()))

a.sort()

absum=0
minabs=10**9
for num in a:
        abnum=abs(num)
        absum+=abnum
        if minabs > abnum:
                minabs=abnum

if a[0] <= 0 and a[-1] >=0:
        print(absum)
else:
        print(absum - 2*minabs)
        num1=a.pop(0)
        num2=a.pop(-1)
        if abs(num1) > abs(num2):
                print(num2,num1)
                a.append(num2-num1)
        else:
                print(num1,num2)
                a.append(num1-num2)
a.sort()
#print(a)

now = a[0]
for i in range(len(a)-2,-1,-1):
        if a[i] > 0:
                print(now, a[i])
                now-=a[i]
#print(now)
a[0]=now

now = a[-1]

for i in range(len(a)-1):
        if a[i] >0:
                break
        print(now,a[i])
        now-=a[i]