from collections import deque

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

a.sort()

if a[0] >= 0:
    m = sum(a[1:]) - a[0]
    print(m)
    p = a.pop(0)
    while len(a) > 1:
        b = a.pop(0)
        print(*[p, b])
        p -= b
    b = a.pop()
    print(*[b, p])
elif a[-1] <= 0:
    m = -sum(a[:-1])+a[-1]
    print(m)
    p = a.pop(-1)
    while len(a) > 0:
        b = a.pop(0)
        print(*[p, b])
        p -= b
else:
    mi = list(filter(lambda x: x < 0, a))
    pl = list(filter(lambda x: x >= 0, a))
    m = -sum(mi) + sum(pl)
    print(m)
    lp = pl.pop(0)
    mi = deque(mi)
    while len(pl) > 0:
        b = pl.pop()
        c = mi.pop()
        print(*[c, b])
        c -= b
        mi.append(c)
    while len(mi) > 0:
        b = mi.pop()
        print(*[lp, b])
        lp -= b 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 if a[0] >= 0:
    m = sum(a[1:]) - a[0]
    print(m)
    p = a.pop(0)
    while len(a) > 1:
        b = a.pop(0)
        print(*[p, b])
        p -= b
    b = a.pop()
    print(*[b, p])
elif a[-1] <= 0:
    m = -sum(a[:-1])+a[-1]
    print(m)
    p = a.pop(-1)
    while len(a) > 0:
        b = a.pop(0)
        print(*[p, b])
        p -= b
else:
    mi = list(filter(lambda x: x < 0, a))
    pl = list(filter(lambda x: x >= 0, a))
    m = -sum(mi) + sum(pl)
    print(m)
    lp = pl.pop(0)
    mi = deque(mi)
    while len(pl) > 0:
        b = pl.pop()
        c = mi.pop()
        print(*[c, b])
        c -= b
        mi.append(c)
    while len(mi) > 0:
        b = mi.pop()
        print(*[lp, b])
        lp -= b a[0] >= 0 a[0] a 0 0 m = sum(a[1:]) - a[0] m sum(a[1:]) - a[0] sum(a[1:]) sum a[1:] a 1: 1 a[0] a 0 print(m) print m p = a.pop(0) p a.pop(0) a.pop a pop 0 while len(a) > 1:
        b = a.pop(0)
        print(*[p, b])
        p -= b
     len(a) > 1 len(a) len a 1 b = a.pop(0) b a.pop(0) a.pop a pop 0 print(*[p, b]) print *[p, b] [p, b] p b p -= b p b b = a.pop() b a.pop() a.pop a pop print(*[b, p]) print *[b, p] [b, p] b p elif a[-1] <= 0:
    m = -sum(a[:-1])+a[-1]
    print(m)
    p = a.pop(-1)
    while len(a) > 0:
        b = a.pop(0)
        print(*[p, b])
        p -= b a[-1] <= 0 a[-1] a -1 0 m = -sum(a[:-1])+a[-1] m -sum(a[:-1])+a[-1] -sum(a[:-1]) sum(a[:-1]) sum a[:-1] a :-1 -1 a[-1] a -1 print(m) print m p = a.pop(-1) p a.pop(-1) a.pop a pop -1 while len(a) > 0:
        b = a.pop(0)
        print(*[p, b])
        p -= b len(a) > 0 len(a) len a 0 b = a.pop(0) b a.pop(0) a.pop a pop 0 print(*[p, b]) print *[p, b] [p, b] p b p -= b p b mi = list(filter(lambda x: x < 0, a)) mi list(filter(lambda x: x < 0, a)) list filter(lambda x: x < 0, a) filter lambda x: x < 0 x < 0 x 0 x a pl = list(filter(lambda x: x >= 0, a)) pl list(filter(lambda x: x >= 0, a)) list filter(lambda x: x >= 0, a) filter lambda x: x >= 0 x >= 0 x 0 x a m = -sum(mi) + sum(pl) m -sum(mi) + sum(pl) -sum(mi) sum(mi) sum mi sum(pl) sum pl print(m) print m lp = pl.pop(0) lp pl.pop(0) pl.pop pl pop 0 mi = deque(mi) mi deque(mi) deque mi while len(pl) > 0:
        b = pl.pop()
        c = mi.pop()
        print(*[c, b])
        c -= b
        mi.append(c)
     len(pl) > 0 len(pl) len pl 0 b = pl.pop() b pl.pop() pl.pop pl pop c = mi.pop() c mi.pop() mi.pop mi pop print(*[c, b]) print *[c, b] [c, b] c b c -= b c b mi.append(c) mi.append mi append c while len(mi) > 0:
        b = mi.pop()
        print(*[lp, b])
        lp -= b len(mi) > 0 len(mi) len mi 0 b = mi.pop() b mi.pop() mi.pop mi pop print(*[lp, b]) print *[lp, b] [lp, b] lp b lp -= b lp b b = a.pop() a.pop() b pl = list(filter(lambda x: x >= 0, a)) list(filter(lambda x: x >= 0, a)) pl mi = deque(mi) deque(mi) mi c = mi.pop() mi.pop() c p -= b b p a = list(map(int, input().split())) list(map(int, input().split())) a m = sum(a[1:]) - a[0] sum(a[1:]) - a[0] m b = a.pop(0) a.pop(0) b mi = list(filter(lambda x: x < 0, a)) list(filter(lambda x: x < 0, a)) mi m = -sum(a[:-1])+a[-1] -sum(a[:-1])+a[-1] m b = a.pop(0) a.pop(0) b p -= b b p b = mi.pop() mi.pop() b lp = pl.pop(0) pl.pop(0) lp c -= b b c b = pl.pop() pl.pop() b p = a.pop(0) a.pop(0) p m = -sum(mi) + sum(pl) -sum(mi) + sum(pl) m lp -= b b lp n = int(input()) int(input()) n p = a.pop(-1) a.pop(-1) p
from collections import deque

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

a.sort()

if a[0] >= 0:
    m = sum(a[1:]) - a[0]
    print(m)
    p = a.pop(0)
    while len(a) > 1:
        b = a.pop(0)
        print(*[p, b])
        p -= b
    b = a.pop()
    print(*[b, p])
elif a[-1] <= 0:
    m = -sum(a[:-1])+a[-1]
    print(m)
    p = a.pop(-1)
    while len(a) > 0:
        b = a.pop(0)
        print(*[p, b])
        p -= b
else:
    mi = list(filter(lambda x: x < 0, a))
    pl = list(filter(lambda x: x >= 0, a))
    m = -sum(mi) + sum(pl)
    print(m)
    lp = pl.pop(0)
    mi = deque(mi)
    while len(pl) > 0:
        b = pl.pop()
        c = mi.pop()
        print(*[c, b])
        c -= b
        mi.append(c)
    while len(mi) > 0:
        b = mi.pop()
        print(*[lp, b])
        lp -= b
