import sys,math,collections,itertools,bisect
input = sys.stdin.readline

N=int(input())
A=sorted(list(map(int,input().split())))
process = []
for i in range(N-2):
    tmp = A.pop()
    y=A.pop()
    A.append(tmp)
    if y>=0:
        process.append([A[0],y])
        A[0]-=y
    else:
        process.append([A[-1],y])
        A[-1]-=y
process.append([A[-1],A[0]])
print(A[-1]-A[0])
for pro in process:
    print(*pro) import sys,math,collections,itertools,bisect sys math collections itertools bisect input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N=int(input()) N int(input()) int input() input A=sorted(list(map(int,input().split()))) A sorted(list(map(int,input().split()))) sorted list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split process = [] process [] for i in range(N-2):
    tmp = A.pop()
    y=A.pop()
    A.append(tmp)
    if y>=0:
        process.append([A[0],y])
        A[0]-=y
    else:
        process.append([A[-1],y])
        A[-1]-=y i range(N-2) range N-2 N 2 tmp = A.pop() tmp A.pop() A.pop A pop y=A.pop() y A.pop() A.pop A pop A.append(tmp) A.append A append tmp if y>=0:
        process.append([A[0],y])
        A[0]-=y
    else:
        process.append([A[-1],y])
        A[-1]-=y y>=0 y 0 process.append([A[0],y]) process.append process append [A[0],y] A[0] A 0 y A[0]-=y A[0] A 0 y process.append([A[-1],y]) process.append process append [A[-1],y] A[-1] A -1 y A[-1]-=y A[-1] A -1 y process.append([A[-1],A[0]]) process.append process append [A[-1],A[0]] A[-1] A -1 A[0] A 0 print(A[-1]-A[0]) print A[-1]-A[0] A[-1] A -1 A[0] A 0 for pro in process:
    print(*pro) pro process print(*pro) print *pro pro input = sys.stdin.readline sys.stdin.readline input A=sorted(list(map(int,input().split()))) sorted(list(map(int,input().split()))) A process = [] [] process tmp = A.pop() A.pop() tmp N=int(input()) int(input()) N y=A.pop() A.pop() y
import sys,math,collections,itertools,bisect
input = sys.stdin.readline

N=int(input())
A=sorted(list(map(int,input().split())))
process = []
for i in range(N-2):
    tmp = A.pop()
    y=A.pop()
    A.append(tmp)
    if y>=0:
        process.append([A[0],y])
        A[0]-=y
    else:
        process.append([A[-1],y])
        A[-1]-=y
process.append([A[-1],A[0]])
print(A[-1]-A[0])
for pro in process:
    print(*pro)
