N = int(input())
A = sorted([int(a) for a in input().split()])
print(A[-1]-A[0]+sum([abs(a) for a in A[1:-1]]))

p = A[-1]
for i in range(N-1):
    a, b = max(p, A[i]), min(p, A[i])
    if i == N-2 or A[i+1] < 0:
        print(a, b)
        p = a - b
    else:
        print(b, a)
        p = b - a N = int(input()) N int(input()) int input() input int(a) for a in input().split() for a in input().split() a input().split() ().split () input split for a in input().split() int(a) int a A = sorted([int(a) for a in input().split()]) A sorted([int(a) for a in input().split()]) sorted [int(a) for a in input().split()] abs(a) for a in A[1:-1] for a in A[1:-1] a A[1:-1] A 1:-1 1 -1 for a in A[1:-1] abs(a) abs a print(A[-1]-A[0]+sum([abs(a) for a in A[1:-1]])) print A[-1]-A[0]+sum([abs(a) for a in A[1:-1]]) A[-1]-A[0] A[-1] A -1 A[0] A 0 sum([abs(a) for a in A[1:-1]]) sum [abs(a) for a in A[1:-1]] p = A[-1] p A[-1] A -1 for i in range(N-1):
    a, b = max(p, A[i]), min(p, A[i])
    if i == N-2 or A[i+1] < 0:
        print(a, b)
        p = a - b
    else:
        print(b, a)
        p = b - a i range(N-1) range N-1 N 1 a, b = max(p, A[i]), min(p, A[i]) a max(p, A[i]) max p A[i] A i b min(p, A[i]) min p A[i] A i if i == N-2 or A[i+1] < 0:
        print(a, b)
        p = a - b
    else:
        print(b, a)
        p = b - a i == N-2 or A[i+1] < 0 i == N-2 i N-2 N 2 A[i+1] < 0 A[i+1] A i+1 i 1 0 print(a, b) print a b p = a - b p a - b a b print(b, a) print b a p = b - a p b - a b a N = int(input()) int(input()) N b = max(p, A[i]), min(p, A[i]) min(p, A[i]) b A = sorted([int(a) for a in input().split()]) sorted([int(a) for a in input().split()]) A p = A[-1] A[-1] p p = b - a b - a p p = a - b a - b p a, b = max(p, A[i]), min(p, A[i]) max(p, A[i]) a
N = int(input())
A = sorted([int(a) for a in input().split()])
print(A[-1]-A[0]+sum([abs(a) for a in A[1:-1]]))

p = A[-1]
for i in range(N-1):
    a, b = max(p, A[i]), min(p, A[i])
    if i == N-2 or A[i+1] < 0:
        print(a, b)
        p = a - b
    else:
        print(b, a)
        p = b - a