def successive_subtraction(N, A, i=1, l=[]):
    mx = max(A)
    mn = min(A)
    if i == N - 1:
        print(mx - mn)
        return l
    l.append((mn, mx))
    A.remove(mn)
    A.remove(mx)
    A.append(mn - mx)
    return successive_subtraction(N, A, i + 1, l)

N = int(input())
A = [int(e) for e in input().split()]
A.sort()
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.pop(0)
print(A[1] - A[0])
l.append((A[1], A[0]))
for v in l:
    print(v[0], v[1]) def successive_subtraction(N, A, i=1, l=[]):
    mx = max(A)
    mn = min(A)
    if i == N - 1:
        print(mx - mn)
        return l
    l.append((mn, mx))
    A.remove(mn)
    A.remove(mx)
    A.append(mn - mx)
    return successive_subtraction(N, A, i + 1, l) successive_subtraction mx = max(A) mx max(A) max A mn = min(A) mn min(A) min A if i == N - 1:
        print(mx - mn)
        return l
     i == N - 1 i N - 1 N 1 print(mx - mn) print mx - mn mx mn return l l l.append((mn, mx)) l.append l append (mn, mx) mn mx A.remove(mn) A.remove A remove mn A.remove(mx) A.remove A remove mx A.append(mn - mx) A.append A append mn - mx mn mx return successive_subtraction(N, A, i + 1, l) successive_subtraction(N, A, i + 1, l) successive_subtraction N A i + 1 i 1 l N N A A i=1 i 1 l=[] l [] N = int(input()) N int(input()) int input() input 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 A = [int(e) for e in input().split()] A [int(e) for e in input().split()] A.sort() A.sort A sort 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.pop(0) 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.pop(0) A.pop A pop 0 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 def successive_subtraction(N, A, i=1, l=[]):
    mx = max(A)
    mn = min(A)
    if i == N - 1:
        print(mx - mn)
        return l
    l.append((mn, mx))
    A.remove(mn)
    A.remove(mx)
    A.append(mn - mx)
    return successive_subtraction(N, A, i + 1, l) def successive_subtraction(N, A, i=1, l=[]):
    mx = max(A)
    mn = min(A)
    if i == N - 1:
        print(mx - mn)
        return l
    l.append((mn, mx))
    A.remove(mn)
    A.remove(mx)
    A.append(mn - mx)
    return successive_subtraction(N, A, i + 1, l) successive_subtraction N = int(input()) int(input()) N l = [] [] l A = [int(e) for e in input().split()] [int(e) for e in input().split()] A
def successive_subtraction(N, A, i=1, l=[]):
    mx = max(A)
    mn = min(A)
    if i == N - 1:
        print(mx - mn)
        return l
    l.append((mn, mx))
    A.remove(mn)
    A.remove(mx)
    A.append(mn - mx)
    return successive_subtraction(N, A, i + 1, l)

N = int(input())
A = [int(e) for e in input().split()]
A.sort()
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.pop(0)
print(A[1] - A[0])
l.append((A[1], A[0]))
for v in l:
    print(v[0], v[1])