n = int(eval(input()))

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

a.sort()

if a[0] >= 0:

    print((sum(a) - 2 * min(a)))

    if n == 2:

        print((a[1], a[0]))

    else:

        print((a[0], a[1]))

        now = a[0] - a[1]

        for i in range(2, n-1):

            print((now, a[i]))

            now = now - a[i]

        print((a[-1], now))

elif a[-1] <= 0:

    print((sum(map(abs, a)) + 2 * max(a)))

    b = a[::-1]

    print((b[0], b[1]))

    now = b[0] - b[1]

    for i in range(2, n):

        print((now, b[i]))

        now -= b[i]

else:

    print((sum(map(abs, a))))

    if n == 2:

        print((a[1], a[0]))

        exit()

    hu = list([x for x in a if x<0])

    se = list([x for x in a if x>=0])

    if len(se) == 1:

        print((a[-1], a[0]))

        now = a[-1] - a[0]

        for i in range(1, n-1):

            print((now, a[i]))

            now = now - a[i]

    else:

        print((hu[0], se[0]))

        now = hu[0] - se[0]

        for i in range(1, len(se)-1):

            print((now, se[i]))

            now -= se[i]

        print((se[-1], now))

        now = se[-1] - now

        for i in range(1, len(hu)):

            print((now, hu[i]))

            now -= hu[i]

n = int(eval(input()))

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

a.sort()



print((a[-1] - a[0] + sum(map(abs, a[1:-1]))))



pos = [a[-1]]

neg = [a[0]]

for x in a[1:-1]:

    if x > 0:

        pos.append(x)

    else:

        neg.append(x)

now = neg[0]

for p in pos[1:]:

    print((now, p))

    now -= p

print((pos[0], now))

now = pos[0] - now

for n in neg[1:]:

    print((now, n))

    now -= n

n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
if a[0] >= 0:
    print((sum(a) - 2 * min(a)))
    if n == 2:
        print((a[1], a[0]))
    else:
        print((a[0], a[1]))
        now = a[0] - a[1]
        for i in range(2, n - 1):
            print((now, a[i]))
            now = now - a[i]
        print((a[-1], now))
elif a[-1] <= 0:
    print((sum(map(abs, a)) + 2 * max(a)))
    b = a[::-1]
    print((b[0], b[1]))
    now = b[0] - b[1]
    for i in range(2, n):
        print((now, b[i]))
        now -= b[i]
else:
    print((sum(map(abs, a))))
    if n == 2:
        print((a[1], a[0]))
        exit()
    hu = list([x for x in a if x < 0])
    se = list([x for x in a if x >= 0])
    if len(se) == 1:
        print((a[-1], a[0]))
        now = a[-1] - a[0]
        for i in range(1, n - 1):
            print((now, a[i]))
            now = now - a[i]
    else:
        print((hu[0], se[0]))
        now = hu[0] - se[0]
        for i in range(1, len(se) - 1):
            print((now, se[i]))
            now -= se[i]
        print((se[-1], now))
        now = se[-1] - now
        for i in range(1, len(hu)):
            print((now, hu[i]))
            now -= hu[i]

n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
print((a[-1] - a[0] + sum(map(abs, a[1:-1]))))
pos = [a[-1]]
neg = [a[0]]
for x in a[1:-1]:
    if x > 0:
        pos.append(x)
    else:
        neg.append(x)
now = neg[0]
for p in pos[1:]:
    print((now, p))
    now -= p
print((pos[0], now))
now = pos[0] - now
for n in neg[1:]:
    print((now, n))
    now -= n

-if a[0] >= 0: -    print((sum(a) - 2 * min(a))) -    if n == 2: -        print((a[1], a[0])) +print((a[-1] - a[0] + sum(map(abs, a[1:-1])))) +pos = [a[-1]] +neg = [a[0]] +for x in a[1:-1]: +    if x > 0: +        pos.append(x) -        print((a[0], a[1])) -        now = a[0] - a[1] -        for i in range(2, n - 1): -            print((now, a[i])) -            now = now - a[i] -        print((a[-1], now)) -elif a[-1] <= 0: -    print((sum(map(abs, a)) + 2 * max(a))) -    b = a[::-1] -    print((b[0], b[1])) -    now = b[0] - b[1] -    for i in range(2, n): -        print((now, b[i])) -        now -= b[i] -else: -    print((sum(map(abs, a)))) -    if n == 2: -        print((a[1], a[0])) -        exit() -    hu = list([x for x in a if x < 0]) -    se = list([x for x in a if x >= 0]) -    if len(se) == 1: -        print((a[-1], a[0])) -        now = a[-1] - a[0] -        for i in range(1, n - 1): -            print((now, a[i])) -            now = now - a[i] -    else: -        print((hu[0], se[0])) -        now = hu[0] - se[0] -        for i in range(1, len(se) - 1): -            print((now, se[i])) -            now -= se[i] -        print((se[-1], now)) -        now = se[-1] - now -        for i in range(1, len(hu)): -            print((now, hu[i])) -            now -= hu[i] +        neg.append(x) +now = neg[0] +for p in pos[1:]: +    print((now, p)) +    now -= p +print((pos[0], now)) +now = pos[0] - now +for n in neg[1:]: +    print((now, n)) +    now -= n