There are N integers, A_1, A_2, ..., A_N, written on a blackboard.  We will repeat the following operation N-1 times so that we have only one integer on the blackboard.    * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.  Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.
import itertools

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

A.sort()


A_sum = list(itertools.accumulate(A))

M = A_sum[-1] - A_sum[(N//2-1)] * 2
print(M)

smaller = A[:(N//2)]
larger = A[(N//2):]

if N % 2 == 0:
    x = larger.pop()
    y = smaller.pop()
    for i in range(N-1):
        if i == 0:
            print(x, y)
            new = x - y
        elif i % 2 == 1:
            x = smaller.pop()
            print(x, new)
            new = x - new
        else:
            x = larger.pop()
            print(x, new)
            new = x - new
else:
    x = smaller.pop()
    y = larger.pop()
    for i in range(N-1):
        if i == 0:
            print(x, y)
            new = x - y
        elif i % 2 == 1:
            x = larger.pop()
            print(x, new)
            new = x - new
        else:
            x = smaller.pop()
            print(x, new)
            new = x - new
    
    


from collections import deque
import bisect

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

A.sort()
A
P, Q = 0, 0
for i in range(N):
    if A[i] >= 0:
        P += 1
    else:
        Q += 1

if P == 0:
    P, Q = 1, N-1
if Q == 0:
    P, Q = N-1, 1

A_p = deque(A[Q:])
A_q = deque(A[:Q])
ans = []
while len(A_p) > 1:
    x = A_q.popleft()
    y = A_p.popleft()
    ans.append([x, y])
    z = x - y
    A_q.appendleft(z)

while A_q:
    x = A_p.pop()
    y = A_q.popleft()
    ans.append([x, y])
    A_p.append(x - y)

M = A_p.pop()
print(M)
for i in range(N-1):
    print(*ans[i])
    

        
    