from collections import deque

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

A_pos = [x for x in A if x >= 0]  # プラスとして使うもの
A_minus = [x for x in A if x < 0]  # マイナスとして使うもの
if len(A_pos) == 0:
    max_tmp = A_minus[-1]
    A_minus = A_minus[:-1]
    A_pos.append(max_tmp)

if len(A_minus) == 0:
    min_tmp = A_pos[0]
    A_pos = A_pos[1:]
    A_minus.append(min_tmp)

A_pos = deque(A_pos)
A_minus = deque(A_minus)

# calc steps
while True:
    if len(A_pos) == 1 and len(A_minus) == 1:
        break
    if len(A_pos) == 1:
        pos = A_pos.pop()
        minus = A_minus.pop()
        steps.append((pos, minus))
        pos -= minus
        A_pos.append(pos)
        continue
    if len(A_minus) == 1:
        # Then len(A_pos) > 1
        pos = A_pos.pop()
        minus = A_minus.pop()
        steps.append((minus, pos))
        minus -= pos
        A_minus.append(minus)
        continue
    pos = A_pos.pop()
    minus = A_minus.pop()
    steps.append((pos, minus))
    pos -= minus
    A_pos.append(pos)

pos = A_pos.pop()
minus = A_minus.pop()

steps.append((pos, minus))
print(pos - minus)
for x, y in steps:
    print('{} {}'.format(x, y)) 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 = sorted(A) A sorted(A) sorted A steps = list() steps list() list x for x in A if x >= 0 for x in A if x >= 0 x A x >= 0 x 0 if x >= 0 x A_pos = [x for x in A if x >= 0] A_pos [x for x in A if x >= 0] x for x in A if x < 0 for x in A if x < 0 x A x < 0 x 0 if x < 0 x A_minus = [x for x in A if x < 0] A_minus [x for x in A if x < 0] if len(A_pos) == 0:
    max_tmp = A_minus[-1]
    A_minus = A_minus[:-1]
    A_pos.append(max_tmp) len(A_pos) == 0 len(A_pos) len A_pos 0 max_tmp = A_minus[-1] max_tmp A_minus[-1] A_minus -1 A_minus = A_minus[:-1] A_minus A_minus[:-1] A_minus :-1 -1 A_pos.append(max_tmp) A_pos.append A_pos append max_tmp if len(A_minus) == 0:
    min_tmp = A_pos[0]
    A_pos = A_pos[1:]
    A_minus.append(min_tmp) len(A_minus) == 0 len(A_minus) len A_minus 0 min_tmp = A_pos[0] min_tmp A_pos[0] A_pos 0 A_pos = A_pos[1:] A_pos A_pos[1:] A_pos 1: 1 A_minus.append(min_tmp) A_minus.append A_minus append min_tmp A_pos = deque(A_pos) A_pos deque(A_pos) deque A_pos A_minus = deque(A_minus) A_minus deque(A_minus) deque A_minus while True:
    if len(A_pos) == 1 and len(A_minus) == 1:
        break
    if len(A_pos) == 1:
        pos = A_pos.pop()
        minus = A_minus.pop()
        steps.append((pos, minus))
        pos -= minus
        A_pos.append(pos)
        continue
    if len(A_minus) == 1:
        # Then len(A_pos) > 1
        pos = A_pos.pop()
        minus = A_minus.pop()
        steps.append((minus, pos))
        minus -= pos
        A_minus.append(minus)
        continue
    pos = A_pos.pop()
    minus = A_minus.pop()
    steps.append((pos, minus))
    pos -= minus
    A_pos.append(pos) True if len(A_pos) == 1 and len(A_minus) == 1:
        break
     len(A_pos) == 1 and len(A_minus) == 1 len(A_pos) == 1 len(A_pos) len A_pos 1 len(A_minus) == 1 len(A_minus) len A_minus 1 break if len(A_pos) == 1:
        pos = A_pos.pop()
        minus = A_minus.pop()
        steps.append((pos, minus))
        pos -= minus
        A_pos.append(pos)
        continue
     len(A_pos) == 1 len(A_pos) len A_pos 1 pos = A_pos.pop() pos A_pos.pop() A_pos.pop A_pos pop minus = A_minus.pop() minus A_minus.pop() A_minus.pop A_minus pop steps.append((pos, minus)) steps.append steps append (pos, minus) pos minus pos -= minus pos minus A_pos.append(pos) A_pos.append A_pos append pos continue if len(A_minus) == 1:
        # Then len(A_pos) > 1
        pos = A_pos.pop()
        minus = A_minus.pop()
        steps.append((minus, pos))
        minus -= pos
        A_minus.append(minus)
        continue
     len(A_minus) == 1 len(A_minus) len A_minus 1 pos = A_pos.pop() pos A_pos.pop() A_pos.pop A_pos pop minus = A_minus.pop() minus A_minus.pop() A_minus.pop A_minus pop steps.append((minus, pos)) steps.append steps append (minus, pos) minus pos minus -= pos minus pos A_minus.append(minus) A_minus.append A_minus append minus continue pos = A_pos.pop() pos A_pos.pop() A_pos.pop A_pos pop minus = A_minus.pop() minus A_minus.pop() A_minus.pop A_minus pop steps.append((pos, minus)) steps.append steps append (pos, minus) pos minus pos -= minus pos minus A_pos.append(pos) A_pos.append A_pos append pos pos = A_pos.pop() pos A_pos.pop() A_pos.pop A_pos pop minus = A_minus.pop() minus A_minus.pop() A_minus.pop A_minus pop steps.append((pos, minus)) steps.append steps append (pos, minus) pos minus print(pos - minus) print pos - minus pos minus for x, y in steps:
    print('{} {}'.format(x, y)) x y steps print('{} {}'.format(x, y)) print '{} {}'.format(x, y) '{} {}'.format '{} {}' format x y A_pos = [x for x in A if x >= 0] [x for x in A if x >= 0] A_pos minus = A_minus.pop() A_minus.pop() minus A_pos = A_pos[1:] A_pos[1:] A_pos minus = A_minus.pop() A_minus.pop() minus minus -= pos pos minus pos -= minus minus pos pos = A_pos.pop() A_pos.pop() pos pos = A_pos.pop() A_pos.pop() pos max_tmp = A_minus[-1] A_minus[-1] max_tmp N = int(input()) int(input()) N A = sorted(A) sorted(A) A A = list(map(int, input().split())) list(map(int, input().split())) A A_minus = A_minus[:-1] A_minus[:-1] A_minus A_pos = deque(A_pos) deque(A_pos) A_pos pos = A_pos.pop() A_pos.pop() pos pos = A_pos.pop() A_pos.pop() pos A_minus = deque(A_minus) deque(A_minus) A_minus minus = A_minus.pop() A_minus.pop() minus steps = list() list() steps A_minus = [x for x in A if x < 0] [x for x in A if x < 0] A_minus minus = A_minus.pop() A_minus.pop() minus min_tmp = A_pos[0] A_pos[0] min_tmp pos -= minus minus pos
from collections import deque

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

A_pos = [x for x in A if x >= 0]  # プラスとして使うもの
A_minus = [x for x in A if x < 0]  # マイナスとして使うもの
if len(A_pos) == 0:
    max_tmp = A_minus[-1]
    A_minus = A_minus[:-1]
    A_pos.append(max_tmp)

if len(A_minus) == 0:
    min_tmp = A_pos[0]
    A_pos = A_pos[1:]
    A_minus.append(min_tmp)

A_pos = deque(A_pos)
A_minus = deque(A_minus)

# calc steps
while True:
    if len(A_pos) == 1 and len(A_minus) == 1:
        break
    if len(A_pos) == 1:
        pos = A_pos.pop()
        minus = A_minus.pop()
        steps.append((pos, minus))
        pos -= minus
        A_pos.append(pos)
        continue
    if len(A_minus) == 1:
        # Then len(A_pos) > 1
        pos = A_pos.pop()
        minus = A_minus.pop()
        steps.append((minus, pos))
        minus -= pos
        A_minus.append(minus)
        continue
    pos = A_pos.pop()
    minus = A_minus.pop()
    steps.append((pos, minus))
    pos -= minus
    A_pos.append(pos)

pos = A_pos.pop()
minus = A_minus.pop()

steps.append((pos, minus))
print(pos - minus)
for x, y in steps:
    print('{} {}'.format(x, y))