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

mn = A[0]
mx = A[-1]
if N ==2:
    print(A[1] - A[0])
    print(A[1],A[0])
    sys.exit()
ope = []
for a in A[1:-1]:
    if a <=0:
        ope.append([mx, a])
        mx -= a
    else:
        ope.append([mn, a])
        mn -= a
ope.append([mx,mn])
print(mx-mn)
for o in ope:
    print(o[0],o[1]) import sys sys 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 mn = A[0] mn A[0] A 0 mx = A[-1] mx A[-1] A -1 if N ==2:
    print(A[1] - A[0])
    print(A[1],A[0])
    sys.exit() N ==2 N 2 print(A[1] - A[0]) print A[1] - A[0] A[1] A 1 A[0] A 0 print(A[1],A[0]) print A[1] A 1 A[0] A 0 sys.exit() sys.exit sys exit ope = [] ope [] for a in A[1:-1]:
    if a <=0:
        ope.append([mx, a])
        mx -= a
    else:
        ope.append([mn, a])
        mn -= a a A[1:-1] A 1:-1 1 -1 if a <=0:
        ope.append([mx, a])
        mx -= a
    else:
        ope.append([mn, a])
        mn -= a a <=0 a 0 ope.append([mx, a]) ope.append ope append [mx, a] mx a mx -= a mx a ope.append([mn, a]) ope.append ope append [mn, a] mn a mn -= a mn a ope.append([mx,mn]) ope.append ope append [mx,mn] mx mn print(mx-mn) print mx-mn mx mn for o in ope:
    print(o[0],o[1]) o ope print(o[0],o[1]) print o[0] o 0 o[1] o 1 A = sorted(list(map(int,input().split()))) sorted(list(map(int,input().split()))) A mn = A[0] A[0] mn ope = [] [] ope N = int(input()) int(input()) N mx -= a a mx mn -= a a mn mx = A[-1] A[-1] mx
import sys
N = int(input())
A = sorted(list(map(int,input().split())))

mn = A[0]
mx = A[-1]
if N ==2:
    print(A[1] - A[0])
    print(A[1],A[0])
    sys.exit()
ope = []
for a in A[1:-1]:
    if a <=0:
        ope.append([mx, a])
        mx -= a
    else:
        ope.append([mn, a])
        mn -= a
ope.append([mx,mn])
print(mx-mn)
for o in ope:
    print(o[0],o[1])