n = int(input())
lis = list(map(int,input().split()))
minus,plus = [],[]
for num in lis:
    if num >= 0:
        plus.append(num)
    elif num < 0:
        minus.append(num)
plus.sort()
minus.sort(reverse=True)
ans = []
if len(plus) == 0:
    now = minus.pop(0)
    for num in minus:
        ans.append([now,num])
        now -= num
    print(now)
elif len(minus) == 0:
    now = plus.pop(0)
    last_num = plus.pop(0)
    for num in plus:
        ans.append([now,num])
        now -= num
    ans.append([last_num,now])
    last_num -= now
    print(last_num)
else:
    now = minus.pop(0)
    last_num = plus.pop(0)
    for num in plus:
        ans.append([now,num])
        now -= num
    for num in minus:
        ans.append([last_num,num])
        last_num -= num
    ans.append([last_num,now])
    last_num -= now
    print(last_num)
for i in range(n-1):
    print(*ans[i]) n = int(input()) n int(input()) int input() input lis = list(map(int,input().split())) lis list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split minus,plus = [],[] minus [] plus [] for num in lis:
    if num >= 0:
        plus.append(num)
    elif num < 0:
        minus.append(num) num lis if num >= 0:
        plus.append(num)
    elif num < 0:
        minus.append(num) num >= 0 num 0 plus.append(num) plus.append plus append num elif num < 0:
        minus.append(num) num < 0 num 0 minus.append(num) minus.append minus append num plus.sort() plus.sort plus sort minus.sort(reverse=True) minus.sort minus sort reverse=True reverse True ans = [] ans [] if len(plus) == 0:
    now = minus.pop(0)
    for num in minus:
        ans.append([now,num])
        now -= num
    print(now)
elif len(minus) == 0:
    now = plus.pop(0)
    last_num = plus.pop(0)
    for num in plus:
        ans.append([now,num])
        now -= num
    ans.append([last_num,now])
    last_num -= now
    print(last_num)
else:
    now = minus.pop(0)
    last_num = plus.pop(0)
    for num in plus:
        ans.append([now,num])
        now -= num
    for num in minus:
        ans.append([last_num,num])
        last_num -= num
    ans.append([last_num,now])
    last_num -= now
    print(last_num) len(plus) == 0 len(plus) len plus 0 now = minus.pop(0) now minus.pop(0) minus.pop minus pop 0 for num in minus:
        ans.append([now,num])
        now -= num
     num minus ans.append([now,num]) ans.append ans append [now,num] now num now -= num now num print(now) print now elif len(minus) == 0:
    now = plus.pop(0)
    last_num = plus.pop(0)
    for num in plus:
        ans.append([now,num])
        now -= num
    ans.append([last_num,now])
    last_num -= now
    print(last_num) len(minus) == 0 len(minus) len minus 0 now = plus.pop(0) now plus.pop(0) plus.pop plus pop 0 last_num = plus.pop(0) last_num plus.pop(0) plus.pop plus pop 0 for num in plus:
        ans.append([now,num])
        now -= num
     num plus ans.append([now,num]) ans.append ans append [now,num] now num now -= num now num ans.append([last_num,now]) ans.append ans append [last_num,now] last_num now last_num -= now last_num now print(last_num) print last_num now = minus.pop(0) now minus.pop(0) minus.pop minus pop 0 last_num = plus.pop(0) last_num plus.pop(0) plus.pop plus pop 0 for num in plus:
        ans.append([now,num])
        now -= num
     num plus ans.append([now,num]) ans.append ans append [now,num] now num now -= num now num for num in minus:
        ans.append([last_num,num])
        last_num -= num
     num minus ans.append([last_num,num]) ans.append ans append [last_num,num] last_num num last_num -= num last_num num ans.append([last_num,now]) ans.append ans append [last_num,now] last_num now last_num -= now last_num now print(last_num) print last_num for i in range(n-1):
    print(*ans[i]) i range(n-1) range n-1 n 1 print(*ans[i]) print *ans[i] ans[i] ans i lis = list(map(int,input().split())) list(map(int,input().split())) lis now = minus.pop(0) minus.pop(0) now last_num = plus.pop(0) plus.pop(0) last_num now -= num num now now = minus.pop(0) minus.pop(0) now last_num -= now now last_num last_num = plus.pop(0) plus.pop(0) last_num now -= num num now n = int(input()) int(input()) n plus = [],[] [] plus now -= num num now last_num -= num num last_num last_num -= now now last_num now = plus.pop(0) plus.pop(0) now minus,plus = [],[] [] minus ans = [] [] ans
n = int(input())
lis = list(map(int,input().split()))
minus,plus = [],[]
for num in lis:
    if num >= 0:
        plus.append(num)
    elif num < 0:
        minus.append(num)
plus.sort()
minus.sort(reverse=True)
ans = []
if len(plus) == 0:
    now = minus.pop(0)
    for num in minus:
        ans.append([now,num])
        now -= num
    print(now)
elif len(minus) == 0:
    now = plus.pop(0)
    last_num = plus.pop(0)
    for num in plus:
        ans.append([now,num])
        now -= num
    ans.append([last_num,now])
    last_num -= now
    print(last_num)
else:
    now = minus.pop(0)
    last_num = plus.pop(0)
    for num in plus:
        ans.append([now,num])
        now -= num
    for num in minus:
        ans.append([last_num,num])
        last_num -= num
    ans.append([last_num,now])
    last_num -= now
    print(last_num)
for i in range(n-1):
    print(*ans[i])