from collections import deque

N = int(eval(input()))

A = (list(map(int, input().split())))

A = sorted(A)

A = deque(A)

l = []

for i in range(N - 1):

    if i == N - 2:

        ans = A[1] - A[0]

        l.append("{} {}".format(A[1], A[0]))

    elif i == N - 3:

        left = A.popleft()

        right = A.pop()

        center = A.pop()



        temp_left = abs(right - (left - center))

        temp_right = abs(left - (right - center))



        if temp_left >= temp_right:

            A.appendleft(left - center)

            A.append(right)

            l.append("{} {}".format(left, center))

        else:

            A.append(right - center)

            A.appendleft(left)

            l.append("{} {}".format(right, center))





    else:

        left = A.popleft()

        left2 = A.popleft()

        right = A.pop()

        right2 = A.pop()

        

        temp_left = abs(right - (left - right2))

        temp_right = abs(left - (right - left2))

        if temp_left >= temp_right:

            A.appendleft(left2)

            A.appendleft(left - right2)

            A.append(right)

            l.append("{} {}".format(left, right2))

        else:

            A.append(right2)

            A.append(right - left2)

            A.appendleft(left)

            l.append("{} {}".format(right, left2))



print(ans)

for line in l:

    print(line)
N = int(eval(input()))

A = list(map(int, input().split()))

A = sorted(A)



leftest_val = A[0]

rightest_val = A[-1]

left_idx = 1

right_idx = N - 2

history = []

for i in range(N - 1):

    left_val = A[left_idx]

    right_val = A[right_idx]

    if i == N - 2:

        history.append("{} {}".format(rightest_val, leftest_val))

        print((rightest_val - leftest_val))

    elif left_val < 0:

        history.append("{} {}".format(rightest_val, left_val))

        rightest_val -= left_val

        left_idx += 1

    else:

        history.append("{} {}".format(leftest_val, right_val))

        leftest_val -= right_val

        right_idx -= 1



for h in history:

    print(h)
from collections import deque

N = int(eval(input()))
A = list(map(int, input().split()))
A = sorted(A)
A = deque(A)
l = []
for i in range(N - 1):
    if i == N - 2:
        ans = A[1] - A[0]
        l.append("{} {}".format(A[1], A[0]))
    elif i == N - 3:
        left = A.popleft()
        right = A.pop()
        center = A.pop()
        temp_left = abs(right - (left - center))
        temp_right = abs(left - (right - center))
        if temp_left >= temp_right:
            A.appendleft(left - center)
            A.append(right)
            l.append("{} {}".format(left, center))
        else:
            A.append(right - center)
            A.appendleft(left)
            l.append("{} {}".format(right, center))
    else:
        left = A.popleft()
        left2 = A.popleft()
        right = A.pop()
        right2 = A.pop()
        temp_left = abs(right - (left - right2))
        temp_right = abs(left - (right - left2))
        if temp_left >= temp_right:
            A.appendleft(left2)
            A.appendleft(left - right2)
            A.append(right)
            l.append("{} {}".format(left, right2))
        else:
            A.append(right2)
            A.append(right - left2)
            A.appendleft(left)
            l.append("{} {}".format(right, left2))
print(ans)
for line in l:
    print(line)

N = int(eval(input()))
A = list(map(int, input().split()))
A = sorted(A)
leftest_val = A[0]
rightest_val = A[-1]
left_idx = 1
right_idx = N - 2
history = []
for i in range(N - 1):
    left_val = A[left_idx]
    right_val = A[right_idx]
    if i == N - 2:
        history.append("{} {}".format(rightest_val, leftest_val))
        print((rightest_val - leftest_val))
    elif left_val < 0:
        history.append("{} {}".format(rightest_val, left_val))
        rightest_val -= left_val
        left_idx += 1
    else:
        history.append("{} {}".format(leftest_val, right_val))
        leftest_val -= right_val
        right_idx -= 1
for h in history:
    print(h)

-from collections import deque - -A = deque(A) -l = [] +leftest_val = A[0] +rightest_val = A[-1] +left_idx = 1 +right_idx = N - 2 +history = [] +    left_val = A[left_idx] +    right_val = A[right_idx] -        ans = A[1] - A[0] -        l.append("{} {}".format(A[1], A[0])) -    elif i == N - 3: -        left = A.popleft() -        right = A.pop() -        center = A.pop() -        temp_left = abs(right - (left - center)) -        temp_right = abs(left - (right - center)) -        if temp_left >= temp_right: -            A.appendleft(left - center) -            A.append(right) -            l.append("{} {}".format(left, center)) -        else: -            A.append(right - center) -            A.appendleft(left) -            l.append("{} {}".format(right, center)) +        history.append("{} {}".format(rightest_val, leftest_val)) +        print((rightest_val - leftest_val)) +    elif left_val < 0: +        history.append("{} {}".format(rightest_val, left_val)) +        rightest_val -= left_val +        left_idx += 1 -        left = A.popleft() -        left2 = A.popleft() -        right = A.pop() -        right2 = A.pop() -        temp_left = abs(right - (left - right2)) -        temp_right = abs(left - (right - left2)) -        if temp_left >= temp_right: -            A.appendleft(left2) -            A.appendleft(left - right2) -            A.append(right) -            l.append("{} {}".format(left, right2)) -        else: -            A.append(right2) -            A.append(right - left2) -            A.appendleft(left) -            l.append("{} {}".format(right, left2)) -print(ans) -for line in l: -    print(line) +        history.append("{} {}".format(leftest_val, right_val)) +        leftest_val -= right_val +        right_idx -= 1 +for h in history: +    print(h)