import bisect
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
sum_L = sum(L)
N_neg = bisect.bisect_left(L, 0)
process = []
if N_neg == 0:  # minのみ-にする
    ans = sum_L-min(L)*2
    l = min(L)
    for r in L[1:-1]:
        process.append(str(l)+" "+str(r))
        l -= r
    process.append(str(L[-1])+" "+str(l))
elif N_neg == N:  # maxのみを+にする
    ans = -sum_L+max(L)*2
    l = L[-1]
    for r in reversed(L[:-1]):
        process.append(str(l)+" "+str(r))
        l -= r
else:  # negのやつを-にする
    ans = sum([abs(v) for v in L])
    l = L[0]
    for r in L[N_neg:-1]:
        process.append(str(l)+" "+str(r))
        l -= r
    process.append(str(L[-1])+" "+str(l))
    l = L[-1]-l
    for r in L[1:N_neg]:
        process.append(str(l)+" "+str(r))
        l -= r
print(ans)
print("\n".join(process)) import bisect bisect import sys sys sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N = int(input()) N int(input()) int input() input L = list(map(int, input().split())) L list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split L = sorted(L) L sorted(L) sorted L sum_L = sum(L) sum_L sum(L) sum L N_neg = bisect.bisect_left(L, 0) N_neg bisect.bisect_left(L, 0) bisect.bisect_left bisect bisect_left L 0 process = [] process [] if N_neg == 0:  # minのみ-にする
    ans = sum_L-min(L)*2
    l = min(L)
    for r in L[1:-1]:
        process.append(str(l)+" "+str(r))
        l -= r
    process.append(str(L[-1])+" "+str(l))
elif N_neg == N:  # maxのみを+にする
    ans = -sum_L+max(L)*2
    l = L[-1]
    for r in reversed(L[:-1]):
        process.append(str(l)+" "+str(r))
        l -= r
else:  # negのやつを-にする
    ans = sum([abs(v) for v in L])
    l = L[0]
    for r in L[N_neg:-1]:
        process.append(str(l)+" "+str(r))
        l -= r
    process.append(str(L[-1])+" "+str(l))
    l = L[-1]-l
    for r in L[1:N_neg]:
        process.append(str(l)+" "+str(r))
        l -= r N_neg == 0 N_neg 0 ans = sum_L-min(L)*2 ans sum_L-min(L)*2 sum_L min(L)*2 min(L) min L 2 l = min(L) l min(L) min L for r in L[1:-1]:
        process.append(str(l)+" "+str(r))
        l -= r
     r L[1:-1] L 1:-1 1 -1 process.append(str(l)+" "+str(r)) process.append process append str(l)+" "+str(r) str(l)+" " str(l) str l " " str(r) str r l -= r l r process.append(str(L[-1])+" "+str(l)) process.append process append str(L[-1])+" "+str(l) str(L[-1])+" " str(L[-1]) str L[-1] L -1 " " str(l) str l elif N_neg == N:  # maxのみを+にする
    ans = -sum_L+max(L)*2
    l = L[-1]
    for r in reversed(L[:-1]):
        process.append(str(l)+" "+str(r))
        l -= r N_neg == N N_neg N ans = -sum_L+max(L)*2 ans -sum_L+max(L)*2 -sum_L sum_L max(L)*2 max(L) max L 2 l = L[-1] l L[-1] L -1 for r in reversed(L[:-1]):
        process.append(str(l)+" "+str(r))
        l -= r r reversed(L[:-1]) reversed L[:-1] L :-1 -1 process.append(str(l)+" "+str(r)) process.append process append str(l)+" "+str(r) str(l)+" " str(l) str l " " str(r) str r l -= r l r abs(v) for v in L for v in L v L for v in L abs(v) abs v ans = sum([abs(v) for v in L]) ans sum([abs(v) for v in L]) sum [abs(v) for v in L] l = L[0] l L[0] L 0 for r in L[N_neg:-1]:
        process.append(str(l)+" "+str(r))
        l -= r
     r L[N_neg:-1] L N_neg:-1 N_neg -1 process.append(str(l)+" "+str(r)) process.append process append str(l)+" "+str(r) str(l)+" " str(l) str l " " str(r) str r l -= r l r process.append(str(L[-1])+" "+str(l)) process.append process append str(L[-1])+" "+str(l) str(L[-1])+" " str(L[-1]) str L[-1] L -1 " " str(l) str l l = L[-1]-l l L[-1]-l L[-1] L -1 l for r in L[1:N_neg]:
        process.append(str(l)+" "+str(r))
        l -= r r L[1:N_neg] L 1:N_neg 1 N_neg process.append(str(l)+" "+str(r)) process.append process append str(l)+" "+str(r) str(l)+" " str(l) str l " " str(r) str r l -= r l r print(ans) print ans print("\n".join(process)) print "\n".join(process) "\n".join "\n" join process ans = -sum_L+max(L)*2 -sum_L+max(L)*2 ans l = L[0] L[0] l L = sorted(L) sorted(L) L l = L[-1] L[-1] l N = int(input()) int(input()) N ans = sum_L-min(L)*2 sum_L-min(L)*2 ans sum_L = sum(L) sum(L) sum_L l = L[-1]-l L[-1]-l l l -= r r l l -= r r l N_neg = bisect.bisect_left(L, 0) bisect.bisect_left(L, 0) N_neg l -= r r l input = sys.stdin.readline sys.stdin.readline input l = min(L) min(L) l l -= r r l L = list(map(int, input().split())) list(map(int, input().split())) L process = [] [] process ans = sum([abs(v) for v in L]) sum([abs(v) for v in L]) ans
import bisect
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
sum_L = sum(L)
N_neg = bisect.bisect_left(L, 0)
process = []
if N_neg == 0:  # minのみ-にする
    ans = sum_L-min(L)*2
    l = min(L)
    for r in L[1:-1]:
        process.append(str(l)+" "+str(r))
        l -= r
    process.append(str(L[-1])+" "+str(l))
elif N_neg == N:  # maxのみを+にする
    ans = -sum_L+max(L)*2
    l = L[-1]
    for r in reversed(L[:-1]):
        process.append(str(l)+" "+str(r))
        l -= r
else:  # negのやつを-にする
    ans = sum([abs(v) for v in L])
    l = L[0]
    for r in L[N_neg:-1]:
        process.append(str(l)+" "+str(r))
        l -= r
    process.append(str(L[-1])+" "+str(l))
    l = L[-1]-l
    for r in L[1:N_neg]:
        process.append(str(l)+" "+str(r))
        l -= r
print(ans)
print("\n".join(process))
