import bisect

N = int(input())
A = sorted([int(i) for i in input().split()])

zp = bisect.bisect_left(A, 0)
ans = []

M = A[0]
for i in range(max(zp, 1), N-1):
    ans.append((M, A[i]))
    M -= A[i]

ans.append((A[N-1], M))
M = A[N-1]-M

for i in range(1, min(zp, N-1)):
    ans.append((M, A[i]))
    M -= A[i]


print(M)
for a, b in ans:
    print(a, b) import bisect bisect N = int(input()) N int(input()) int input() input int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i A = sorted([int(i) for i in input().split()]) A sorted([int(i) for i in input().split()]) sorted [int(i) for i in input().split()] zp = bisect.bisect_left(A, 0) zp bisect.bisect_left(A, 0) bisect.bisect_left bisect bisect_left A 0 ans = [] ans [] M = A[0] M A[0] A 0 for i in range(max(zp, 1), N-1):
    ans.append((M, A[i]))
    M -= A[i] i range(max(zp, 1), N-1) range max(zp, 1) max zp 1 N-1 N 1 ans.append((M, A[i])) ans.append ans append (M, A[i]) M A[i] A i M -= A[i] M A[i] A i ans.append((A[N-1], M)) ans.append ans append (A[N-1], M) A[N-1] A N-1 N 1 M M = A[N-1]-M M A[N-1]-M A[N-1] A N-1 N 1 M for i in range(1, min(zp, N-1)):
    ans.append((M, A[i]))
    M -= A[i] i range(1, min(zp, N-1)) range 1 min(zp, N-1) min zp N-1 N 1 ans.append((M, A[i])) ans.append ans append (M, A[i]) M A[i] A i M -= A[i] M A[i] A i print(M) print M for a, b in ans:
    print(a, b) a b ans print(a, b) print a b ans = [] [] ans M -= A[i] A[i] M N = int(input()) int(input()) N A = sorted([int(i) for i in input().split()]) sorted([int(i) for i in input().split()]) A M -= A[i] A[i] M M = A[N-1]-M A[N-1]-M M zp = bisect.bisect_left(A, 0) bisect.bisect_left(A, 0) zp M = A[0] A[0] M
import bisect

N = int(input())
A = sorted([int(i) for i in input().split()])

zp = bisect.bisect_left(A, 0)
ans = []

M = A[0]
for i in range(max(zp, 1), N-1):
    ans.append((M, A[i]))
    M -= A[i]

ans.append((A[N-1], M))
M = A[N-1]-M

for i in range(1, min(zp, N-1)):
    ans.append((M, A[i]))
    M -= A[i]


print(M)
for a, b in ans:
    print(a, b)
