from collections import deque

N = int(input())
A = deque(maxlen=N)
x = [int(e) for e in input().split()]
x.sort()
for a in x:
    A.append(a)
l = []
for i in range(N - 2):
    (a, b, c) = (A[0], A[1], A[-1])
    if b < 0:
        l.append((c, a))
        A[-1] = c - a
    else:
        l.append((a, b))
        A[1] = a - b
    A.popleft()
print(A[1] - A[0])
l.append((A[1], A[0]))
for v in l:
    print(v[0], v[1]) from collections import deque N = int(input()) N int(input()) int input() input A = deque(maxlen=N) A deque(maxlen=N) deque maxlen=N maxlen N int(e) for e in input().split() for e in input().split() e input().split() ().split () input split for e in input().split() int(e) int e x = [int(e) for e in input().split()] x [int(e) for e in input().split()] x.sort() x.sort x sort for a in x:
    A.append(a) a x A.append(a) A.append A append a l = [] l [] for i in range(N - 2):
    (a, b, c) = (A[0], A[1], A[-1])
    if b < 0:
        l.append((c, a))
        A[-1] = c - a
    else:
        l.append((a, b))
        A[1] = a - b
    A.popleft() i range(N - 2) range N - 2 N 2 (a, b, c) = (A[0], A[1], A[-1]) (a, b, c) a b c (A[0], A[1], A[-1]) A[0] A 0 A[1] A 1 A[-1] A -1 if b < 0:
        l.append((c, a))
        A[-1] = c - a
    else:
        l.append((a, b))
        A[1] = a - b
     b < 0 b 0 l.append((c, a)) l.append l append (c, a) c a A[-1] = c - a A[-1] A -1 c - a c a l.append((a, b)) l.append l append (a, b) a b A[1] = a - b A[1] A 1 a - b a b A.popleft() A.popleft A popleft print(A[1] - A[0]) print A[1] - A[0] A[1] A 1 A[0] A 0 l.append((A[1], A[0])) l.append l append (A[1], A[0]) A[1] A 1 A[0] A 0 for v in l:
    print(v[0], v[1]) v l print(v[0], v[1]) print v[0] v 0 v[1] v 1 A = deque(maxlen=N) deque(maxlen=N) A x = [int(e) for e in input().split()] [int(e) for e in input().split()] x N = int(input()) int(input()) N l = [] [] l
from collections import deque

N = int(input())
A = deque(maxlen=N)
x = [int(e) for e in input().split()]
x.sort()
for a in x:
    A.append(a)
l = []
for i in range(N - 2):
    (a, b, c) = (A[0], A[1], A[-1])
    if b < 0:
        l.append((c, a))
        A[-1] = c - a
    else:
        l.append((a, b))
        A[1] = a - b
    A.popleft()
print(A[1] - A[0])
l.append((A[1], A[0]))
for v in l:
    print(v[0], v[1])