import sys
input = sys.stdin.readline

N = int(input())
As = list(map(int, input().split()))

history = []

positives = []
negatives = []
for A in As:
    if A >= 0:
        positives.append(A)
    else:
        negatives.append(A)

if not positives:
    n = max(negatives)
    negatives.remove(n)
    positives.append(n)

if not negatives:
    p = min(positives)
    positives.remove(p)
    negatives.append(p)

while len(negatives) > 1:
    p = positives.pop()
    n = negatives.pop()
    history.append((p, n))
    positives.append(p-n)

n = negatives[0]
while len(positives) > 1:
    p = positives.pop()
    history.append((n, p))
    n -= p

history.append((positives[0], n))
ans = positives[0] - n

print(ans)
for elem in history:
    print(*elem) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N = int(input()) N int(input()) int input() input As = list(map(int, input().split())) As list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split history = [] history [] positives = [] positives [] negatives = [] negatives [] for A in As:
    if A >= 0:
        positives.append(A)
    else:
        negatives.append(A) A As if A >= 0:
        positives.append(A)
    else:
        negatives.append(A) A >= 0 A 0 positives.append(A) positives.append positives append A negatives.append(A) negatives.append negatives append A if not positives:
    n = max(negatives)
    negatives.remove(n)
    positives.append(n) not positives positives n = max(negatives) n max(negatives) max negatives negatives.remove(n) negatives.remove negatives remove n positives.append(n) positives.append positives append n if not negatives:
    p = min(positives)
    positives.remove(p)
    negatives.append(p) not negatives negatives p = min(positives) p min(positives) min positives positives.remove(p) positives.remove positives remove p negatives.append(p) negatives.append negatives append p while len(negatives) > 1:
    p = positives.pop()
    n = negatives.pop()
    history.append((p, n))
    positives.append(p-n) len(negatives) > 1 len(negatives) len negatives 1 p = positives.pop() p positives.pop() positives.pop positives pop n = negatives.pop() n negatives.pop() negatives.pop negatives pop history.append((p, n)) history.append history append (p, n) p n positives.append(p-n) positives.append positives append p-n p n n = negatives[0] n negatives[0] negatives 0 while len(positives) > 1:
    p = positives.pop()
    history.append((n, p))
    n -= p len(positives) > 1 len(positives) len positives 1 p = positives.pop() p positives.pop() positives.pop positives pop history.append((n, p)) history.append history append (n, p) n p n -= p n p history.append((positives[0], n)) history.append history append (positives[0], n) positives[0] positives 0 n ans = positives[0] - n ans positives[0] - n positives[0] positives 0 n print(ans) print ans for elem in history:
    print(*elem) elem history print(*elem) print *elem elem p = min(positives) min(positives) p n -= p p n input = sys.stdin.readline sys.stdin.readline input p = positives.pop() positives.pop() p p = positives.pop() positives.pop() p negatives = [] [] negatives N = int(input()) int(input()) N n = negatives[0] negatives[0] n history = [] [] history n = negatives.pop() negatives.pop() n positives = [] [] positives ans = positives[0] - n positives[0] - n ans As = list(map(int, input().split())) list(map(int, input().split())) As n = max(negatives) max(negatives) n
import sys
input = sys.stdin.readline

N = int(input())
As = list(map(int, input().split()))

history = []

positives = []
negatives = []
for A in As:
    if A >= 0:
        positives.append(A)
    else:
        negatives.append(A)

if not positives:
    n = max(negatives)
    negatives.remove(n)
    positives.append(n)

if not negatives:
    p = min(positives)
    positives.remove(p)
    negatives.append(p)

while len(negatives) > 1:
    p = positives.pop()
    n = negatives.pop()
    history.append((p, n))
    positives.append(p-n)

n = negatives[0]
while len(positives) > 1:
    p = positives.pop()
    history.append((n, p))
    n -= p

history.append((positives[0], n))
ans = positives[0] - n

print(ans)
for elem in history:
    print(*elem)