import sys
from bisect import bisect_left

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
A.sort()
# -の合計数は最大N-1、最小N//2
minus = bisect_left(A, 0)
# minusは負の数の個数
m = min(minus, N-1)
if m == 0: m += 1
# mは最終的にマイナスにする数
answer = -sum(A[:m]) + sum(A[m:])
print(answer)
cur = A[0]
for i in range(m, N-1):
    print(cur, A[i])
    cur -= A[i]

A[0] = cur
cur = A[N-1]
for i in range(m):
    print(cur, A[i])
    cur -= A[i]

# 53 import sys sys from bisect import bisect_left sr = lambda: sys.stdin.readline().rstrip() sr lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip ir = lambda: int(sr()) ir lambda: int(sr()) int(sr()) int sr() sr lr = lambda: list(map(int, sr().split())) lr lambda: list(map(int, sr().split())) list(map(int, sr().split())) list map(int, sr().split()) map int sr().split() ().split () sr split N = ir() N ir() ir A = lr() A lr() lr A.sort() A.sort A sort minus = bisect_left(A, 0) minus bisect_left(A, 0) bisect_left A 0 m = min(minus, N-1) m min(minus, N-1) min minus N-1 N 1 if m == 0: m += 1
# mは最終的にマイナスにする数 m == 0 m 0 answer = -sum(A[:m]) + sum(A[m:]) answer -sum(A[:m]) + sum(A[m:]) -sum(A[:m]) sum(A[:m]) sum A[:m] A :m m sum(A[m:]) sum A[m:] A m: m print(answer) print answer cur = A[0] cur A[0] A 0 for i in range(m, N-1):
    print(cur, A[i])
    cur -= A[i] i range(m, N-1) range m N-1 N 1 print(cur, A[i]) print cur A[i] A i cur -= A[i] cur A[i] A i A[0] = cur A[0] A 0 cur cur = A[N-1] cur A[N-1] A N-1 N 1 for i in range(m):
    print(cur, A[i])
    cur -= A[i]

# 53 i range(m) range m print(cur, A[i]) print cur A[i] A i cur -= A[i] cur A[i] A i cur = A[N-1] A[N-1] cur lr = lambda: list(map(int, sr().split())) lambda: list(map(int, sr().split())) lr N = ir() ir() N A = lr() lr() A minus = bisect_left(A, 0) bisect_left(A, 0) minus ir = lambda: int(sr()) lambda: int(sr()) ir answer = -sum(A[:m]) + sum(A[m:]) -sum(A[:m]) + sum(A[m:]) answer m = min(minus, N-1) min(minus, N-1) m cur -= A[i] A[i] cur sr = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() sr cur = A[0] A[0] cur cur -= A[i] A[i] cur
import sys
from bisect import bisect_left

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
A.sort()
# -の合計数は最大N-1、最小N//2
minus = bisect_left(A, 0)
# minusは負の数の個数
m = min(minus, N-1)
if m == 0: m += 1
# mは最終的にマイナスにする数
answer = -sum(A[:m]) + sum(A[m:])
print(answer)
cur = A[0]
for i in range(m, N-1):
    print(cur, A[i])
    cur -= A[i]

A[0] = cur
cur = A[N-1]
for i in range(m):
    print(cur, A[i])
    cur -= A[i]

# 53
