from collections import deque

N = int(input())
a = deque(sorted(map(int, input().split())))


max_a = a.pop()
min_a = a.popleft()

ans_s = ""
while True:
    if len(a) <= 0:
        ans_s += "{} {}\n".format(max_a, min_a)
        ans = max_a - min_a
        break

    if max_a <= 0:
        ans_s += "{} {}\n".format(max_a, min_a)
        max_a -= min_a

        min_a = a.popleft()
    elif min_a >= 0:
        ans_s += "{} {}\n".format(min_a, max_a)
        min_a -= max_a

        max_a = a.pop()
    else:
        w = a.pop()
        if w < 0:
            ans_s += "{} {}\n".format(max_a, w)
            max_a -= w
        else:
            ans_s += "{} {}\n".format(min_a, w)
            min_a -= w

print(ans)
print(ans_s, end="")
 from collections import deque N = int(input()) N int(input()) int input() input a = deque(sorted(map(int, input().split()))) a deque(sorted(map(int, input().split()))) deque sorted(map(int, input().split())) sorted map(int, input().split()) map int input().split() ().split () input split max_a = a.pop() max_a a.pop() a.pop a pop min_a = a.popleft() min_a a.popleft() a.popleft a popleft ans_s = "" ans_s "" while True:
    if len(a) <= 0:
        ans_s += "{} {}\n".format(max_a, min_a)
        ans = max_a - min_a
        break

    if max_a <= 0:
        ans_s += "{} {}\n".format(max_a, min_a)
        max_a -= min_a

        min_a = a.popleft()
    elif min_a >= 0:
        ans_s += "{} {}\n".format(min_a, max_a)
        min_a -= max_a

        max_a = a.pop()
    else:
        w = a.pop()
        if w < 0:
            ans_s += "{} {}\n".format(max_a, w)
            max_a -= w
        else:
            ans_s += "{} {}\n".format(min_a, w)
            min_a -= w True if len(a) <= 0:
        ans_s += "{} {}\n".format(max_a, min_a)
        ans = max_a - min_a
        break

     len(a) <= 0 len(a) len a 0 ans_s += "{} {}\n".format(max_a, min_a) ans_s "{} {}\n".format(max_a, min_a) "{} {}\n".format "{} {}\n" format max_a min_a ans = max_a - min_a ans max_a - min_a max_a min_a break if max_a <= 0:
        ans_s += "{} {}\n".format(max_a, min_a)
        max_a -= min_a

        min_a = a.popleft()
    elif min_a >= 0:
        ans_s += "{} {}\n".format(min_a, max_a)
        min_a -= max_a

        max_a = a.pop()
    else:
        w = a.pop()
        if w < 0:
            ans_s += "{} {}\n".format(max_a, w)
            max_a -= w
        else:
            ans_s += "{} {}\n".format(min_a, w)
            min_a -= w max_a <= 0 max_a 0 ans_s += "{} {}\n".format(max_a, min_a) ans_s "{} {}\n".format(max_a, min_a) "{} {}\n".format "{} {}\n" format max_a min_a max_a -= min_a max_a min_a min_a = a.popleft() min_a a.popleft() a.popleft a popleft elif min_a >= 0:
        ans_s += "{} {}\n".format(min_a, max_a)
        min_a -= max_a

        max_a = a.pop()
     min_a >= 0 min_a 0 ans_s += "{} {}\n".format(min_a, max_a) ans_s "{} {}\n".format(min_a, max_a) "{} {}\n".format "{} {}\n" format min_a max_a min_a -= max_a min_a max_a max_a = a.pop() max_a a.pop() a.pop a pop w = a.pop() w a.pop() a.pop a pop if w < 0:
            ans_s += "{} {}\n".format(max_a, w)
            max_a -= w
        else:
            ans_s += "{} {}\n".format(min_a, w)
            min_a -= w w < 0 w 0 ans_s += "{} {}\n".format(max_a, w) ans_s "{} {}\n".format(max_a, w) "{} {}\n".format "{} {}\n" format max_a w max_a -= w max_a w ans_s += "{} {}\n".format(min_a, w) ans_s "{} {}\n".format(min_a, w) "{} {}\n".format "{} {}\n" format min_a w min_a -= w min_a w print(ans) print ans print(ans_s, end="") print ans_s end="" end "" ans_s += "{} {}\n".format(max_a, w) "{} {}\n".format(max_a, w) ans_s min_a -= max_a max_a min_a max_a = a.pop() a.pop() max_a ans_s += "{} {}\n".format(min_a, max_a) "{} {}\n".format(min_a, max_a) ans_s ans_s += "{} {}\n".format(max_a, min_a) "{} {}\n".format(max_a, min_a) ans_s ans_s += "{} {}\n".format(max_a, min_a) "{} {}\n".format(max_a, min_a) ans_s ans_s += "{} {}\n".format(min_a, w) "{} {}\n".format(min_a, w) ans_s max_a -= w w max_a min_a -= w w min_a max_a = a.pop() a.pop() max_a min_a = a.popleft() a.popleft() min_a ans = max_a - min_a max_a - min_a ans a = deque(sorted(map(int, input().split()))) deque(sorted(map(int, input().split()))) a ans_s = "" "" ans_s w = a.pop() a.pop() w max_a -= min_a min_a max_a N = int(input()) int(input()) N min_a = a.popleft() a.popleft() min_a
from collections import deque

N = int(input())
a = deque(sorted(map(int, input().split())))


max_a = a.pop()
min_a = a.popleft()

ans_s = ""
while True:
    if len(a) <= 0:
        ans_s += "{} {}\n".format(max_a, min_a)
        ans = max_a - min_a
        break

    if max_a <= 0:
        ans_s += "{} {}\n".format(max_a, min_a)
        max_a -= min_a

        min_a = a.popleft()
    elif min_a >= 0:
        ans_s += "{} {}\n".format(min_a, max_a)
        min_a -= max_a

        max_a = a.pop()
    else:
        w = a.pop()
        if w < 0:
            ans_s += "{} {}\n".format(max_a, w)
            max_a -= w
        else:
            ans_s += "{} {}\n".format(min_a, w)
            min_a -= w

print(ans)
print(ans_s, end="")

