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