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

if n==2:
    print(max(al)-min(al))
    print(max(al),min(al))
    exit()

pos = []
neg = []
for a in al:
    if a>=0:
        pos.append(a)
    else:
        neg.append(a)

pos.sort()
neg.sort(reverse=True)
res = []

if len(pos)==0:
    x = neg[0]
    for a in neg[1:]:
        res.append((x,a))
        x -= a
elif len(neg)==0:
    x = pos[0]
    for a in pos[1:-1]:
        res.append((x,a))
        x -= a
    res.append((pos[-1],x))
    x = pos[-1]-x
else:
    p = pos[0]
    pos = pos[1:]

    x = neg[0]
    neg = neg[1:]

    for a in pos:
        res.append((x,a))
        x -= a
    res.append((p,x))
    x = p - x
    for a in neg:
        res.append((x,a))
        x -= a


print(x)
for a,b in res:
    print(a,b) n = int(input()) n int(input()) int input() input al = list(map(int, input().split())) al list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split if n==2:
    print(max(al)-min(al))
    print(max(al),min(al))
    exit() n==2 n 2 print(max(al)-min(al)) print max(al)-min(al) max(al) max al min(al) min al print(max(al),min(al)) print max(al) max al min(al) min al exit() exit pos = [] pos [] neg = [] neg [] for a in al:
    if a>=0:
        pos.append(a)
    else:
        neg.append(a) a al if a>=0:
        pos.append(a)
    else:
        neg.append(a) a>=0 a 0 pos.append(a) pos.append pos append a neg.append(a) neg.append neg append a pos.sort() pos.sort pos sort neg.sort(reverse=True) neg.sort neg sort reverse=True reverse True res = [] res [] if len(pos)==0:
    x = neg[0]
    for a in neg[1:]:
        res.append((x,a))
        x -= a
elif len(neg)==0:
    x = pos[0]
    for a in pos[1:-1]:
        res.append((x,a))
        x -= a
    res.append((pos[-1],x))
    x = pos[-1]-x
else:
    p = pos[0]
    pos = pos[1:]

    x = neg[0]
    neg = neg[1:]

    for a in pos:
        res.append((x,a))
        x -= a
    res.append((p,x))
    x = p - x
    for a in neg:
        res.append((x,a))
        x -= a len(pos)==0 len(pos) len pos 0 x = neg[0] x neg[0] neg 0 for a in neg[1:]:
        res.append((x,a))
        x -= a a neg[1:] neg 1: 1 res.append((x,a)) res.append res append (x,a) x a x -= a x a elif len(neg)==0:
    x = pos[0]
    for a in pos[1:-1]:
        res.append((x,a))
        x -= a
    res.append((pos[-1],x))
    x = pos[-1]-x len(neg)==0 len(neg) len neg 0 x = pos[0] x pos[0] pos 0 for a in pos[1:-1]:
        res.append((x,a))
        x -= a
     a pos[1:-1] pos 1:-1 1 -1 res.append((x,a)) res.append res append (x,a) x a x -= a x a res.append((pos[-1],x)) res.append res append (pos[-1],x) pos[-1] pos -1 x x = pos[-1]-x x pos[-1]-x pos[-1] pos -1 x p = pos[0] p pos[0] pos 0 pos = pos[1:] pos pos[1:] pos 1: 1 x = neg[0] x neg[0] neg 0 neg = neg[1:] neg neg[1:] neg 1: 1 for a in pos:
        res.append((x,a))
        x -= a
     a pos res.append((x,a)) res.append res append (x,a) x a x -= a x a res.append((p,x)) res.append res append (p,x) p x x = p - x x p - x p x for a in neg:
        res.append((x,a))
        x -= a a neg res.append((x,a)) res.append res append (x,a) x a x -= a x a print(x) print x for a,b in res:
    print(a,b) a b res print(a,b) print a b n = int(input()) int(input()) n pos = [] [] pos x = neg[0] neg[0] x neg = neg[1:] neg[1:] neg neg = [] [] neg x = pos[0] pos[0] x pos = pos[1:] pos[1:] pos x = pos[-1]-x pos[-1]-x x res = [] [] res x = neg[0] neg[0] x x = p - x p - x x x -= a a x x -= a a x x -= a a x al = list(map(int, input().split())) list(map(int, input().split())) al x -= a a x p = pos[0] pos[0] p
n = int(input())
al = list(map(int, input().split()))

if n==2:
    print(max(al)-min(al))
    print(max(al),min(al))
    exit()

pos = []
neg = []
for a in al:
    if a>=0:
        pos.append(a)
    else:
        neg.append(a)

pos.sort()
neg.sort(reverse=True)
res = []

if len(pos)==0:
    x = neg[0]
    for a in neg[1:]:
        res.append((x,a))
        x -= a
elif len(neg)==0:
    x = pos[0]
    for a in pos[1:-1]:
        res.append((x,a))
        x -= a
    res.append((pos[-1],x))
    x = pos[-1]-x
else:
    p = pos[0]
    pos = pos[1:]

    x = neg[0]
    neg = neg[1:]

    for a in pos:
        res.append((x,a))
        x -= a
    res.append((p,x))
    x = p - x
    for a in neg:
        res.append((x,a))
        x -= a


print(x)
for a,b in res:
    print(a,b)