import collections
N = int(input())
A = list(map(int, input().split()))
A.sort()
A2 = collections.deque(A)
#print(N, A)
x = [0] * (N-1)
y = [0] * (N-1)
for i in range(N -1):
    amin = A2.popleft()
    amax = A2.pop()
    mainasuflag = 0
    plusflag = 0
    if i != N - 2:
        if A2[0] > 0:
            mainasuflag = 1
        if A2[len(A2) - 1] < 0:
            plusflag = 1
        amin2 = abs(A2[0])
        amax2 = abs(A2[len(A2) -1])
        if i == N - 3:
            if A2[0] > 0:
                A2.appendleft(amin - amax)
                x[i] = amin
                y[i] = amax
            else:
                A2.append(amax - amin)
                x[i] = amax
                y[i] = amin
        else:
            if mainasuflag == 1:
                A2.appendleft(amin - amax)
                x[i] = amin
                y[i] = amax
            elif plusflag == 1:
                A2.append(amax - amin)
                x[i] = amax
                y[i] = amin
            else:
                if amax2 >= amin2:
                    A2.appendleft(amin - amax)
                    x[i] = amin
                    y[i] = amax
                else:
                    A2.append(amax - amin)
                    x[i] = amax
                    y[i] = amin

    else:
        A2.append(amax - amin)
        x[i] = amax
        y[i] = amin

    #print("A", A2, mainasuflag, plusflag)

print(A2[0])
#print(x, y)
for i in range(N - 1):
    print(x[i], y[i]) import collections collections N = int(input()) N int(input()) int input() input A = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split A.sort() A.sort A sort A2 = collections.deque(A) A2 collections.deque(A) collections.deque collections deque A x = [0] * (N-1) x [0] * (N-1) [0] 0 N-1 N 1 y = [0] * (N-1) y [0] * (N-1) [0] 0 N-1 N 1 for i in range(N -1):
    amin = A2.popleft()
    amax = A2.pop()
    mainasuflag = 0
    plusflag = 0
    if i != N - 2:
        if A2[0] > 0:
            mainasuflag = 1
        if A2[len(A2) - 1] < 0:
            plusflag = 1
        amin2 = abs(A2[0])
        amax2 = abs(A2[len(A2) -1])
        if i == N - 3:
            if A2[0] > 0:
                A2.appendleft(amin - amax)
                x[i] = amin
                y[i] = amax
            else:
                A2.append(amax - amin)
                x[i] = amax
                y[i] = amin
        else:
            if mainasuflag == 1:
                A2.appendleft(amin - amax)
                x[i] = amin
                y[i] = amax
            elif plusflag == 1:
                A2.append(amax - amin)
                x[i] = amax
                y[i] = amin
            else:
                if amax2 >= amin2:
                    A2.appendleft(amin - amax)
                    x[i] = amin
                    y[i] = amax
                else:
                    A2.append(amax - amin)
                    x[i] = amax
                    y[i] = amin

    else:
        A2.append(amax - amin)
        x[i] = amax
        y[i] = amin

    #print("A", A2, mainasuflag, plusflag) i range(N -1) range N -1 N 1 amin = A2.popleft() amin A2.popleft() A2.popleft A2 popleft amax = A2.pop() amax A2.pop() A2.pop A2 pop mainasuflag = 0 mainasuflag 0 plusflag = 0 plusflag 0 if i != N - 2:
        if A2[0] > 0:
            mainasuflag = 1
        if A2[len(A2) - 1] < 0:
            plusflag = 1
        amin2 = abs(A2[0])
        amax2 = abs(A2[len(A2) -1])
        if i == N - 3:
            if A2[0] > 0:
                A2.appendleft(amin - amax)
                x[i] = amin
                y[i] = amax
            else:
                A2.append(amax - amin)
                x[i] = amax
                y[i] = amin
        else:
            if mainasuflag == 1:
                A2.appendleft(amin - amax)
                x[i] = amin
                y[i] = amax
            elif plusflag == 1:
                A2.append(amax - amin)
                x[i] = amax
                y[i] = amin
            else:
                if amax2 >= amin2:
                    A2.appendleft(amin - amax)
                    x[i] = amin
                    y[i] = amax
                else:
                    A2.append(amax - amin)
                    x[i] = amax
                    y[i] = amin

    else:
        A2.append(amax - amin)
        x[i] = amax
        y[i] = amin

    #print("A", A2, mainasuflag, plusflag) i != N - 2 i N - 2 N 2 if A2[0] > 0:
            mainasuflag = 1
         A2[0] > 0 A2[0] A2 0 0 mainasuflag = 1 mainasuflag 1 if A2[len(A2) - 1] < 0:
            plusflag = 1
         A2[len(A2) - 1] < 0 A2[len(A2) - 1] A2 len(A2) - 1 len(A2) len A2 1 0 plusflag = 1 plusflag 1 amin2 = abs(A2[0]) amin2 abs(A2[0]) abs A2[0] A2 0 amax2 = abs(A2[len(A2) -1]) amax2 abs(A2[len(A2) -1]) abs A2[len(A2) -1] A2 len(A2) -1 len(A2) len A2 1 if i == N - 3:
            if A2[0] > 0:
                A2.appendleft(amin - amax)
                x[i] = amin
                y[i] = amax
            else:
                A2.append(amax - amin)
                x[i] = amax
                y[i] = amin
        else:
            if mainasuflag == 1:
                A2.appendleft(amin - amax)
                x[i] = amin
                y[i] = amax
            elif plusflag == 1:
                A2.append(amax - amin)
                x[i] = amax
                y[i] = amin
            else:
                if amax2 >= amin2:
                    A2.appendleft(amin - amax)
                    x[i] = amin
                    y[i] = amax
                else:
                    A2.append(amax - amin)
                    x[i] = amax
                    y[i] = amin

     i == N - 3 i N - 3 N 3 if A2[0] > 0:
                A2.appendleft(amin - amax)
                x[i] = amin
                y[i] = amax
            else:
                A2.append(amax - amin)
                x[i] = amax
                y[i] = amin
         A2[0] > 0 A2[0] A2 0 0 A2.appendleft(amin - amax) A2.appendleft A2 appendleft amin - amax amin amax x[i] = amin x[i] x i amin y[i] = amax y[i] y i amax A2.append(amax - amin) A2.append A2 append amax - amin amax amin x[i] = amax x[i] x i amax y[i] = amin y[i] y i amin if mainasuflag == 1:
                A2.appendleft(amin - amax)
                x[i] = amin
                y[i] = amax
            elif plusflag == 1:
                A2.append(amax - amin)
                x[i] = amax
                y[i] = amin
            else:
                if amax2 >= amin2:
                    A2.appendleft(amin - amax)
                    x[i] = amin
                    y[i] = amax
                else:
                    A2.append(amax - amin)
                    x[i] = amax
                    y[i] = amin

     mainasuflag == 1 mainasuflag 1 A2.appendleft(amin - amax) A2.appendleft A2 appendleft amin - amax amin amax x[i] = amin x[i] x i amin y[i] = amax y[i] y i amax elif plusflag == 1:
                A2.append(amax - amin)
                x[i] = amax
                y[i] = amin
             plusflag == 1 plusflag 1 A2.append(amax - amin) A2.append A2 append amax - amin amax amin x[i] = amax x[i] x i amax y[i] = amin y[i] y i amin if amax2 >= amin2:
                    A2.appendleft(amin - amax)
                    x[i] = amin
                    y[i] = amax
                else:
                    A2.append(amax - amin)
                    x[i] = amax
                    y[i] = amin

     amax2 >= amin2 amax2 amin2 A2.appendleft(amin - amax) A2.appendleft A2 appendleft amin - amax amin amax x[i] = amin x[i] x i amin y[i] = amax y[i] y i amax A2.append(amax - amin) A2.append A2 append amax - amin amax amin x[i] = amax x[i] x i amax y[i] = amin y[i] y i amin A2.append(amax - amin) A2.append A2 append amax - amin amax amin x[i] = amax x[i] x i amax y[i] = amin y[i] y i amin print(A2[0]) print A2[0] A2 0 for i in range(N - 1):
    print(x[i], y[i]) i range(N - 1) range N - 1 N 1 print(x[i], y[i]) print x[i] x i y[i] y i y = [0] * (N-1) [0] * (N-1) y mainasuflag = 1 1 mainasuflag amin2 = abs(A2[0]) abs(A2[0]) amin2 A = list(map(int, input().split())) list(map(int, input().split())) A amax = A2.pop() A2.pop() amax plusflag = 0 0 plusflag x = [0] * (N-1) [0] * (N-1) x amax2 = abs(A2[len(A2) -1]) abs(A2[len(A2) -1]) amax2 N = int(input()) int(input()) N amin = A2.popleft() A2.popleft() amin plusflag = 1 1 plusflag A2 = collections.deque(A) collections.deque(A) A2 mainasuflag = 0 0 mainasuflag
import collections
N = int(input())
A = list(map(int, input().split()))
A.sort()
A2 = collections.deque(A)
#print(N, A)
x = [0] * (N-1)
y = [0] * (N-1)
for i in range(N -1):
    amin = A2.popleft()
    amax = A2.pop()
    mainasuflag = 0
    plusflag = 0
    if i != N - 2:
        if A2[0] > 0:
            mainasuflag = 1
        if A2[len(A2) - 1] < 0:
            plusflag = 1
        amin2 = abs(A2[0])
        amax2 = abs(A2[len(A2) -1])
        if i == N - 3:
            if A2[0] > 0:
                A2.appendleft(amin - amax)
                x[i] = amin
                y[i] = amax
            else:
                A2.append(amax - amin)
                x[i] = amax
                y[i] = amin
        else:
            if mainasuflag == 1:
                A2.appendleft(amin - amax)
                x[i] = amin
                y[i] = amax
            elif plusflag == 1:
                A2.append(amax - amin)
                x[i] = amax
                y[i] = amin
            else:
                if amax2 >= amin2:
                    A2.appendleft(amin - amax)
                    x[i] = amin
                    y[i] = amax
                else:
                    A2.append(amax - amin)
                    x[i] = amax
                    y[i] = amin

    else:
        A2.append(amax - amin)
        x[i] = amax
        y[i] = amin

    #print("A", A2, mainasuflag, plusflag)

print(A2[0])
#print(x, y)
for i in range(N - 1):
    print(x[i], y[i])