from collections import deque
n = int(input())
a = list(map(int, input().split()))
a.sort()
a = deque(a)

left = a.popleft()
right = a.pop()

ans = []
for i in a:
    if i > 0:
        ans.append((left, i))
        left -= i
    else:
        ans.append((right, i))
        right -= i
else:
    ans.append((right, left))

print(right-left)
for x, y in ans:
    print(x, y) from collections import deque 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 a = deque(a) a deque(a) deque a left = a.popleft() left a.popleft() a.popleft a popleft right = a.pop() right a.pop() a.pop a pop ans = [] ans [] for i in a:
    if i > 0:
        ans.append((left, i))
        left -= i
    else:
        ans.append((right, i))
        right -= i
else:
    ans.append((right, left)) i a if i > 0:
        ans.append((left, i))
        left -= i
    else:
        ans.append((right, i))
        right -= i i > 0 i 0 ans.append((left, i)) ans.append ans append (left, i) left i left -= i left i ans.append((right, i)) ans.append ans append (right, i) right i right -= i right i ans.append((right, left)) ans.append ans append (right, left) right left print(right-left) print right-left right left for x, y in ans:
    print(x, y) x y ans print(x, y) print x y a = deque(a) deque(a) a a = list(map(int, input().split())) list(map(int, input().split())) a left -= i i left ans = [] [] ans right = a.pop() a.pop() right right -= i i right left = a.popleft() a.popleft() left n = int(input()) int(input()) n
from collections import deque
n = int(input())
a = list(map(int, input().split()))
a.sort()
a = deque(a)

left = a.popleft()
right = a.pop()

ans = []
for i in a:
    if i > 0:
        ans.append((left, i))
        left -= i
    else:
        ans.append((right, i))
        right -= i
else:
    ans.append((right, left))

print(right-left)
for x, y in ans:
    print(x, y)
