N = int(input())
a_list = list(map(int, input().split()))
a_list.sort()

from collections import deque

deq = deque(a_list)
res = []
while len(deq) > 2:
    min_num = deq.popleft()
    max_num = deq.pop()
    if min_num < 0 and max_num > 0:
        ne = deq.pop()
        if ne >= 0:
            res.append((min_num, ne))
            min_num -= ne
            deq.appendleft(min_num)
            deq.append(max_num)
        else:
            res.append((max_num, ne))
            max_num -= ne
            deq.append(max_num)
            deq.appendleft(min_num)
    else:
        if max_num <= 0:
            res.append((max_num, min_num))
            max_num = max_num - min_num
            deq.append(max_num)
        else:
            res.append((min_num, max_num))
            min_num = min_num - max_num
            deq.appendleft(min_num)

tmp1 = deq[0]
tmp2 = deq[1]
res.append((max(tmp1, tmp2), min(tmp2, tmp1)))
ans = max(tmp1, tmp2) - min(tmp2, tmp1)
print(ans)
for x,y in res:
    print(x, y) N = int(input()) N int(input()) int input() input a_list = list(map(int, input().split())) a_list list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split a_list.sort() a_list.sort a_list sort from collections import deque deq = deque(a_list) deq deque(a_list) deque a_list res = [] res [] while len(deq) > 2:
    min_num = deq.popleft()
    max_num = deq.pop()
    if min_num < 0 and max_num > 0:
        ne = deq.pop()
        if ne >= 0:
            res.append((min_num, ne))
            min_num -= ne
            deq.appendleft(min_num)
            deq.append(max_num)
        else:
            res.append((max_num, ne))
            max_num -= ne
            deq.append(max_num)
            deq.appendleft(min_num)
    else:
        if max_num <= 0:
            res.append((max_num, min_num))
            max_num = max_num - min_num
            deq.append(max_num)
        else:
            res.append((min_num, max_num))
            min_num = min_num - max_num
            deq.appendleft(min_num) len(deq) > 2 len(deq) len deq 2 min_num = deq.popleft() min_num deq.popleft() deq.popleft deq popleft max_num = deq.pop() max_num deq.pop() deq.pop deq pop if min_num < 0 and max_num > 0:
        ne = deq.pop()
        if ne >= 0:
            res.append((min_num, ne))
            min_num -= ne
            deq.appendleft(min_num)
            deq.append(max_num)
        else:
            res.append((max_num, ne))
            max_num -= ne
            deq.append(max_num)
            deq.appendleft(min_num)
    else:
        if max_num <= 0:
            res.append((max_num, min_num))
            max_num = max_num - min_num
            deq.append(max_num)
        else:
            res.append((min_num, max_num))
            min_num = min_num - max_num
            deq.appendleft(min_num) min_num < 0 and max_num > 0 min_num < 0 min_num 0 max_num > 0 max_num 0 ne = deq.pop() ne deq.pop() deq.pop deq pop if ne >= 0:
            res.append((min_num, ne))
            min_num -= ne
            deq.appendleft(min_num)
            deq.append(max_num)
        else:
            res.append((max_num, ne))
            max_num -= ne
            deq.append(max_num)
            deq.appendleft(min_num)
     ne >= 0 ne 0 res.append((min_num, ne)) res.append res append (min_num, ne) min_num ne min_num -= ne min_num ne deq.appendleft(min_num) deq.appendleft deq appendleft min_num deq.append(max_num) deq.append deq append max_num res.append((max_num, ne)) res.append res append (max_num, ne) max_num ne max_num -= ne max_num ne deq.append(max_num) deq.append deq append max_num deq.appendleft(min_num) deq.appendleft deq appendleft min_num if max_num <= 0:
            res.append((max_num, min_num))
            max_num = max_num - min_num
            deq.append(max_num)
        else:
            res.append((min_num, max_num))
            min_num = min_num - max_num
            deq.appendleft(min_num) max_num <= 0 max_num 0 res.append((max_num, min_num)) res.append res append (max_num, min_num) max_num min_num max_num = max_num - min_num max_num max_num - min_num max_num min_num deq.append(max_num) deq.append deq append max_num res.append((min_num, max_num)) res.append res append (min_num, max_num) min_num max_num min_num = min_num - max_num min_num min_num - max_num min_num max_num deq.appendleft(min_num) deq.appendleft deq appendleft min_num tmp1 = deq[0] tmp1 deq[0] deq 0 tmp2 = deq[1] tmp2 deq[1] deq 1 res.append((max(tmp1, tmp2), min(tmp2, tmp1))) res.append res append (max(tmp1, tmp2), min(tmp2, tmp1)) max(tmp1, tmp2) max tmp1 tmp2 min(tmp2, tmp1) min tmp2 tmp1 ans = max(tmp1, tmp2) - min(tmp2, tmp1) ans max(tmp1, tmp2) - min(tmp2, tmp1) max(tmp1, tmp2) max tmp1 tmp2 min(tmp2, tmp1) min tmp2 tmp1 print(ans) print ans for x,y in res:
    print(x, y) x y res print(x, y) print x y min_num = min_num - max_num min_num - max_num min_num tmp1 = deq[0] deq[0] tmp1 max_num = deq.pop() deq.pop() max_num min_num -= ne ne min_num max_num -= ne ne max_num N = int(input()) int(input()) N deq = deque(a_list) deque(a_list) deq res = [] [] res max_num = max_num - min_num max_num - min_num max_num tmp2 = deq[1] deq[1] tmp2 a_list = list(map(int, input().split())) list(map(int, input().split())) a_list ne = deq.pop() deq.pop() ne ans = max(tmp1, tmp2) - min(tmp2, tmp1) max(tmp1, tmp2) - min(tmp2, tmp1) ans min_num = deq.popleft() deq.popleft() min_num
N = int(input())
a_list = list(map(int, input().split()))
a_list.sort()

from collections import deque

deq = deque(a_list)
res = []
while len(deq) > 2:
    min_num = deq.popleft()
    max_num = deq.pop()
    if min_num < 0 and max_num > 0:
        ne = deq.pop()
        if ne >= 0:
            res.append((min_num, ne))
            min_num -= ne
            deq.appendleft(min_num)
            deq.append(max_num)
        else:
            res.append((max_num, ne))
            max_num -= ne
            deq.append(max_num)
            deq.appendleft(min_num)
    else:
        if max_num <= 0:
            res.append((max_num, min_num))
            max_num = max_num - min_num
            deq.append(max_num)
        else:
            res.append((min_num, max_num))
            min_num = min_num - max_num
            deq.appendleft(min_num)

tmp1 = deq[0]
tmp2 = deq[1]
res.append((max(tmp1, tmp2), min(tmp2, tmp1)))
ans = max(tmp1, tmp2) - min(tmp2, tmp1)
print(ans)
for x,y in res:
    print(x, y)
