N = int(input())
A = list(map(int, input().split()))
A.sort()

neg = [n for n in A if n < 0]
pos = [n for n in A if n >= 0]

if len(neg) == 0:  # all positive
    x = A.pop(0)
    print(sum(A) - x)
    pivot = A.pop()
    for y in A:
        print(x, y)
        x -= y
    print(pivot, x)
elif len(pos) == 0:  # all negative
    x = A.pop()
    print(x - sum(A))
    for y in A:
        print(x, y)
        x -= y
else:
    print(sum(pos) - sum(neg))
    pivot = pos.pop()
    x = neg.pop()
    for y in pos:
        print(x, y)
        x -= y
    x, pivot = pivot, x
    for y in neg:
        print(x, y)
        x -= y
    print(x, pivot) 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 n for n in A if n < 0 for n in A if n < 0 n A n < 0 n 0 if n < 0 n neg = [n for n in A if n < 0] neg [n for n in A if n < 0] n for n in A if n >= 0 for n in A if n >= 0 n A n >= 0 n 0 if n >= 0 n pos = [n for n in A if n >= 0] pos [n for n in A if n >= 0] if len(neg) == 0:  # all positive
    x = A.pop(0)
    print(sum(A) - x)
    pivot = A.pop()
    for y in A:
        print(x, y)
        x -= y
    print(pivot, x)
elif len(pos) == 0:  # all negative
    x = A.pop()
    print(x - sum(A))
    for y in A:
        print(x, y)
        x -= y
else:
    print(sum(pos) - sum(neg))
    pivot = pos.pop()
    x = neg.pop()
    for y in pos:
        print(x, y)
        x -= y
    x, pivot = pivot, x
    for y in neg:
        print(x, y)
        x -= y
    print(x, pivot) len(neg) == 0 len(neg) len neg 0 x = A.pop(0) x A.pop(0) A.pop A pop 0 print(sum(A) - x) print sum(A) - x sum(A) sum A x pivot = A.pop() pivot A.pop() A.pop A pop for y in A:
        print(x, y)
        x -= y
     y A print(x, y) print x y x -= y x y print(pivot, x) print pivot x elif len(pos) == 0:  # all negative
    x = A.pop()
    print(x - sum(A))
    for y in A:
        print(x, y)
        x -= y len(pos) == 0 len(pos) len pos 0 x = A.pop() x A.pop() A.pop A pop print(x - sum(A)) print x - sum(A) x sum(A) sum A for y in A:
        print(x, y)
        x -= y y A print(x, y) print x y x -= y x y print(sum(pos) - sum(neg)) print sum(pos) - sum(neg) sum(pos) sum pos sum(neg) sum neg pivot = pos.pop() pivot pos.pop() pos.pop pos pop x = neg.pop() x neg.pop() neg.pop neg pop for y in pos:
        print(x, y)
        x -= y
     y pos print(x, y) print x y x -= y x y x, pivot = pivot, x x pivot pivot x for y in neg:
        print(x, y)
        x -= y
     y neg print(x, y) print x y x -= y x y print(x, pivot) print x pivot x -= y y x x = neg.pop() neg.pop() x neg = [n for n in A if n < 0] [n for n in A if n < 0] neg A = list(map(int, input().split())) list(map(int, input().split())) A x -= y y x pivot = pivot, x x pivot N = int(input()) int(input()) N pivot = A.pop() A.pop() pivot pos = [n for n in A if n >= 0] [n for n in A if n >= 0] pos x -= y y x x -= y y x x, pivot = pivot, x pivot x pivot = pos.pop() pos.pop() pivot x = A.pop() A.pop() x x = A.pop(0) A.pop(0) x
N = int(input())
A = list(map(int, input().split()))
A.sort()

neg = [n for n in A if n < 0]
pos = [n for n in A if n >= 0]

if len(neg) == 0:  # all positive
    x = A.pop(0)
    print(sum(A) - x)
    pivot = A.pop()
    for y in A:
        print(x, y)
        x -= y
    print(pivot, x)
elif len(pos) == 0:  # all negative
    x = A.pop()
    print(x - sum(A))
    for y in A:
        print(x, y)
        x -= y
else:
    print(sum(pos) - sum(neg))
    pivot = pos.pop()
    x = neg.pop()
    for y in pos:
        print(x, y)
        x -= y
    x, pivot = pivot, x
    for y in neg:
        print(x, y)
        x -= y
    print(x, pivot)
