from collections import deque

N = int(input())
inpt = input()
A = [int(a) for a in inpt.split()]
A = deque(sorted(A))
outputs = []
negative = 0
positive = 0

for a in A:
    if a > 0:
        positive += 1
    elif a <= 0:
        negative += 1
for i in range(N-1):
    maxA = A[-1]
    minA = A[0]
    if minA>0:
        positive -= 1
    else:
        negative -= 1
    if maxA>0:
        positive -= 1
    else:
        negative -= 1
    A.pop()
    A.popleft()
    if positive > negative:
        newnum = minA-maxA
        A.appendleft(newnum)
        outputs.append(str(minA)+" "+str(maxA))
    else:
        newnum = maxA - minA
        A.append(newnum)
        outputs.append(str(maxA)+" "+str(minA))
    if newnum > 0:
        positive += 1
    else:
        negative += 1

print(A[0])
for output in outputs:
    print(output) from collections import deque N = int(input()) N int(input()) int input() input inpt = input() inpt input() input int(a) for a in inpt.split() for a in inpt.split() a inpt.split() inpt.split inpt split for a in inpt.split() int(a) int a A = [int(a) for a in inpt.split()] A [int(a) for a in inpt.split()] A = deque(sorted(A)) A deque(sorted(A)) deque sorted(A) sorted A outputs = [] outputs [] negative = 0 negative 0 positive = 0 positive 0 for a in A:
    if a > 0:
        positive += 1
    elif a <= 0:
        negative += 1 a A if a > 0:
        positive += 1
    elif a <= 0:
        negative += 1 a > 0 a 0 positive += 1 positive 1 elif a <= 0:
        negative += 1 a <= 0 a 0 negative += 1 negative 1 for i in range(N-1):
    maxA = A[-1]
    minA = A[0]
    if minA>0:
        positive -= 1
    else:
        negative -= 1
    if maxA>0:
        positive -= 1
    else:
        negative -= 1
    A.pop()
    A.popleft()
    if positive > negative:
        newnum = minA-maxA
        A.appendleft(newnum)
        outputs.append(str(minA)+" "+str(maxA))
    else:
        newnum = maxA - minA
        A.append(newnum)
        outputs.append(str(maxA)+" "+str(minA))
    if newnum > 0:
        positive += 1
    else:
        negative += 1 i range(N-1) range N-1 N 1 maxA = A[-1] maxA A[-1] A -1 minA = A[0] minA A[0] A 0 if minA>0:
        positive -= 1
    else:
        negative -= 1
     minA>0 minA 0 positive -= 1 positive 1 negative -= 1 negative 1 if maxA>0:
        positive -= 1
    else:
        negative -= 1
     maxA>0 maxA 0 positive -= 1 positive 1 negative -= 1 negative 1 A.pop() A.pop A pop A.popleft() A.popleft A popleft if positive > negative:
        newnum = minA-maxA
        A.appendleft(newnum)
        outputs.append(str(minA)+" "+str(maxA))
    else:
        newnum = maxA - minA
        A.append(newnum)
        outputs.append(str(maxA)+" "+str(minA))
     positive > negative positive negative newnum = minA-maxA newnum minA-maxA minA maxA A.appendleft(newnum) A.appendleft A appendleft newnum outputs.append(str(minA)+" "+str(maxA)) outputs.append outputs append str(minA)+" "+str(maxA) str(minA)+" " str(minA) str minA " " str(maxA) str maxA newnum = maxA - minA newnum maxA - minA maxA minA A.append(newnum) A.append A append newnum outputs.append(str(maxA)+" "+str(minA)) outputs.append outputs append str(maxA)+" "+str(minA) str(maxA)+" " str(maxA) str maxA " " str(minA) str minA if newnum > 0:
        positive += 1
    else:
        negative += 1 newnum > 0 newnum 0 positive += 1 positive 1 negative += 1 negative 1 print(A[0]) print A[0] A 0 for output in outputs:
    print(output) output outputs print(output) print output negative -= 1 1 negative newnum = minA-maxA minA-maxA newnum N = int(input()) int(input()) N A = deque(sorted(A)) deque(sorted(A)) A positive += 1 1 positive A = [int(a) for a in inpt.split()] [int(a) for a in inpt.split()] A minA = A[0] A[0] minA negative += 1 1 negative positive = 0 0 positive positive -= 1 1 positive positive += 1 1 positive newnum = maxA - minA maxA - minA newnum inpt = input() input() inpt positive -= 1 1 positive negative -= 1 1 negative negative = 0 0 negative negative += 1 1 negative outputs = [] [] outputs maxA = A[-1] A[-1] maxA
from collections import deque

N = int(input())
inpt = input()
A = [int(a) for a in inpt.split()]
A = deque(sorted(A))
outputs = []
negative = 0
positive = 0

for a in A:
    if a > 0:
        positive += 1
    elif a <= 0:
        negative += 1
for i in range(N-1):
    maxA = A[-1]
    minA = A[0]
    if minA>0:
        positive -= 1
    else:
        negative -= 1
    if maxA>0:
        positive -= 1
    else:
        negative -= 1
    A.pop()
    A.popleft()
    if positive > negative:
        newnum = minA-maxA
        A.appendleft(newnum)
        outputs.append(str(minA)+" "+str(maxA))
    else:
        newnum = maxA - minA
        A.append(newnum)
        outputs.append(str(maxA)+" "+str(minA))
    if newnum > 0:
        positive += 1
    else:
        negative += 1

print(A[0])
for output in outputs:
    print(output)
